8

Tôi muốn thực hiện phân cụm với dự án tai. Tôi tìm thấy một giải pháp để chạy độc lập trong phân cụm bằng cách sử dụng cấu hình standalone-ha.xml. Tôi đã theo dõi bài viết dưới đây. Nó hoạt động tốt. Clustering in domain mode with wildfly9 Nhưng tôi muốn chạy dự án ERP có tai cũng như ejb của tiểu bang. Vì vậy, tôi chạy clustering ở chế độ độc lập.Trong wildlfy9, cách tạo bản sao phiên ejb stateful bằng hai nút ở chế độ độc lập (Clustering)

Tôi có hai máy ip khác nhau ví dụ:

1.10.10.10.10 node1

  1. 20.20.20.20 node2

Cả hai máy đã wildfly9 và cho mục đích thử nghiệm Tôi đã tạo ra dự án stateful ejb một mẫu với thành phần web.

lệnh của tôi để chạy máy chủ là:

standalone.bat -c standalone-ha.xml -b 10.10.10.10 -u 230.0.0.4 -Djboss.node.name=node1 

./standalone.sh -c standalone-ha.xml -b 20.20.20.20 -u 230.0.0.4 -Djboss.node.name=node2 

Dự án của tôi Test.war có stateful servlet ejb và và jsp. 1) Bank.java là ejb stateful mà thực hiện từ xa và địa phương giao diện

@Stateful(passivationCapable=true) 
public class Bank implements BankRemote,BankLocal { 

private int amount=0; 

@Override 
public boolean withdraw(int amount) { 
    if(amount<=this.amount){ 
      this.amount-=amount; 
      return true; 
     }else{ 
      return false; 
     } 
} 
@Override 
public void deposit(int amount) { 
    this.amount+=amount; 

} 
@Override 
public int getBalance() { 
    return amount; 
}} 

2) OpenAccount.java là servlet

@WebServlet("/OpenAccount") 
public class OpenAccount extends HttpServlet { 
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
try{ 
     HttpSession bankSession = request.getSession(); 
     BankRemote bank = (BankRemote) bankSession.getAttribute("remote"); 
     if(bank == null) 
      { 
       System.out.println("Session is Null So initialized with new session"); 
       Properties p = new Properties(); 
       /*p.put("jboss.naming.client.ejb.context", true);*/ 
       p.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); 
       InitialContext context=new InitialContext();     
       BankRemote b=(BankRemote)context.lookup("java:global/Test/Bank!com.ejb.BankRemote");     
       request.getSession().setAttribute("remote",b); 
      } 
      else 
      { 
       System.out.println("Session is present id is :["+bankSession.getId()+"]"); 
      } 
      request.getRequestDispatcher("/operation.jsp").forward(request, response); 
} 
    catch(Exception e){System.out.println(e);} 

3) index.jsp là Trang chủ chứa bên dưới dòng duy nhất mà chuyển hướng để servlet

<a href="OpenAccount">Open Account</a> 

4) operation.jsp đó chuyển tiếp từ servlet là:

<body> 
 
<form action="operationprocess.jsp"> 
 
Enter Amount:<input type="text" name="amount"/><br>  
 
Choose Operation: 
 
Deposit<input type="radio" name="operation" value="deposit"/> 
 
Withdraw<input type="radio" name="operation" value="withdraw"/> 
 
Check balance<input type="radio" name="operation" value="checkbalance"/> 
 
<br> 
 
<input type="submit" value="submit"> 
 
</form> 
 
</body>

4) operationprocess.jsp là

<body> 
 
<% 
 
try 
 
{ 
 
BankRemote remote=(BankRemote)session.getAttribute("remote"); 
 
String operation=request.getParameter("operation"); 
 
String amount=request.getParameter("amount");  
 
if(remote != null) 
 
{if(operation!=null){ 
 
try{  
 
    if(operation.equals("deposit")) 
 
    { 
 
     remote.deposit(Integer.parseInt(amount)); 
 
     out.print("Amount successfully deposited!"); 
 
    } 
 
    else 
 
    {    \t 
 
    if(operation.equals("withdraw")){ 
 
     boolean status=remote.withdraw(Integer.parseInt(amount)); 
 
     if(status){ 
 
     out.print("Amount successfully withdrawn!"); } 
 
     else{ 
 
     out.println("Enter less amount"); } 
 
    }else{ 
 
     out.println("Current Amount: "+remote.getBalance()); 
 
    \t } 
 
\t } 
 
\t }catch(NumberFormatException numex){ 
 
\t \t \t out.println("Number is not valid");} 
 
\t } 
 
} 
 
else 
 
{out.print("Session is null"); } 
 
}catch(Exception ee){ 
 
\t System.out.println("in jsp exception"); 
 
\t ee.printStackTrace();} 
 
%> 
 
<hr/> 
 
<jsp:include page="operation.jsp"></jsp:include> 
 
</body>

5) web.xml chứa

<distributable/> 

thẻ cho phép clustering.

6) cũng đường dẫn lớp có jboss-ejb-client.properties

remote.clusters=ejb 
remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false 
remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=false 

Với tất cả những điều này, tôi đã triển khai Test.war trong cả hai máy chủ và cố gắng truy cập với apache_mode_cluster tức 10.10.10.10/Test/ . Nó đang gọi ejb và cung cấp cho tôi đầu ra nhưng khi

1) tôi tắt 10.10.10.10 trình duyệt máy chủ và làm mới (Không rõ ràng lịch sử trình duyệt để duy trì phiên), lúc đó nó cho tôi lỗi như thùng chứa phân phối không áp dụng cho giống hệt nhau ứng dụng.

2) 10.10.10.10 bị tắt và tôi xóa lịch sử và truy cập lại url 10.10.10.10/Test nó chuyển hướng đến 20.20.20.20 máy chủ tức là node2 và chạy thành công. Nhưng phiên không được nhân rộng.

Hãy giúp tôi. độc-ha.xml - hệ thống phụ infinispan là:

<cache-container name="server" default-cache="default" module="org.wildfly.clustering.server" aliases="singleton cluster"> 
      <transport lock-timeout="60000"/> 
      <replicated-cache name="default" mode="SYNC"> 
       <transaction mode="BATCH"/> 
      </replicated-cache> 
     </cache-container> 
     <cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan"> 
      <transport lock-timeout="60000"/> 
      <distributed-cache name="dist" mode="ASYNC" owners="2" l1-lifespan="0"> 
       <locking isolation="REPEATABLE_READ"/> 
       <transaction mode="BATCH"/> 
       <file-store/> 
      </distributed-cache> 
     </cache-container> 
     <cache-container name="ejb" default-cache="dist" module="org.wildfly.clustering.ejb.infinispan" aliases="sfsb"> 
      <transport lock-timeout="60000"/> 
      <distributed-cache name="dist" mode="ASYNC" owners="2" l1-lifespan="0"> 
       <locking isolation="REPEATABLE_READ"/> 
       <transaction mode="BATCH"/> 
       <file-store/> 
      </distributed-cache> 
     </cache-container> 
+1

vui lòng đăng nội dung của hệ thống con inifnispan '' từ tệp 'standalone-ha.xml' của bạn. – Shiva

+1

Thẻ [tag: cluster-analysis] (được phân biệt từ: clustering) đề cập đến nhiệm vụ khai phá dữ liệu, không phải cho máy chủ [tag: load-balancing] hoặc [tag: cluster-computing]. Hãy chú ý hơn đến việc chọn các thẻ thích hợp và mô tả của chúng. –

+1

SCRIPTLETS ????????? o.O –

Trả lời

0

Tôi có vấn đề tương tự (post) và bắt đầu xem bài viết của bạn. Sau một thời gian tôi nhận được những gì gây ra nó.

Có thể bạn có vấn đề tương tự. Kiểm tra nó ra.

Các vấn đề liên quan