private static void _registerClusterOrder( HttpServletRequest request, ClusterNode clusterNode, String orderUuid, String productEntryName, int maxServers) throws Exception { MethodHandler methodHandler = new MethodHandler(_registerOrderMethodKey, orderUuid, productEntryName, maxServers); ClusterRequest clusterRequest = ClusterRequest.createUnicastRequest(methodHandler, clusterNode.getClusterNodeId()); FutureClusterResponses futureClusterResponses = ClusterExecutorUtil.execute(clusterRequest); ClusterNodeResponses clusterNodeResponses = futureClusterResponses.get(20000, TimeUnit.MILLISECONDS); ClusterNodeResponse clusterNodeResponse = clusterNodeResponses.getClusterResponse(clusterNode); Map<String, Object> attributes = (Map<String, Object>) clusterNodeResponse.getResult(); for (Map.Entry<String, Object> entry : attributes.entrySet()) { request.setAttribute( clusterNode.getClusterNodeId() + StringPool.UNDERLINE + entry.getKey(), entry.getValue()); } }
@AdviseWith(adviceClasses = {EnableClusterLinkAdvice.class}) @Test public void testInvoke2() throws Exception { ClusterExecutorImpl clusterExecutorImpl1 = null; ClusterExecutorImpl clusterExecutorImpl2 = null; try { clusterExecutorImpl1 = getClusterExecutorImpl(false, false); clusterExecutorImpl2 = getClusterExecutorImpl(false, false); String timestamp = String.valueOf(System.currentTimeMillis()); MethodHandler methodHandler = new MethodHandler(testMethod1MethodKey, timestamp); Address address = clusterExecutorImpl2.getLocalClusterNodeAddress(); ClusterRequest clusterRequest = ClusterRequest.createUnicastRequest(methodHandler, address); FutureClusterResponses futureClusterResponses = clusterExecutorImpl1.execute(clusterRequest); assertFutureClusterResponsesWithoutException( futureClusterResponses.get(), clusterRequest.getUuid(), timestamp, address); } finally { if (clusterExecutorImpl1 != null) { clusterExecutorImpl1.destroy(); } if (clusterExecutorImpl2 != null) { clusterExecutorImpl2.destroy(); } } }
@AdviseWith(adviceClasses = {EnableClusterLinkAdvice.class}) @Test public void testInvoke6() throws Exception { ClusterExecutorImpl clusterExecutorImpl1 = null; ClusterExecutorImpl clusterExecutorImpl2 = null; try { clusterExecutorImpl1 = getClusterExecutorImpl(false, true); clusterExecutorImpl2 = getClusterExecutorImpl(false, true); MethodHandler methodHandler = new MethodHandler(testMethod4MethodKey); Address address = clusterExecutorImpl2.getLocalClusterNodeAddress(); ClusterRequest clusterRequest = ClusterRequest.createUnicastRequest(methodHandler, address); clusterRequest.setBeanIdentifier(BEAN_IDENTIFIER); FutureClusterResponses futureClusterResponses = clusterExecutorImpl1.execute(clusterRequest); assertFutureClusterResponsesWithoutException( futureClusterResponses.get(), clusterRequest.getUuid(), SERIALIZABLE_RETRUN_VALUE, address); } finally { if (clusterExecutorImpl1 != null) { clusterExecutorImpl1.destroy(); } if (clusterExecutorImpl2 != null) { clusterExecutorImpl2.destroy(); } } }
@Override public void execute( ClusterRequest clusterRequest, ClusterResponseCallback clusterResponseCallback) { FutureClusterResponses futureClusterResponses = execute(clusterRequest); try { clusterResponseCallback.callback(futureClusterResponses.get()); } catch (InterruptedException ie) { } }
@Override public void execute( ClusterRequest clusterRequest, ClusterResponseCallback clusterResponseCallback, long timeout, TimeUnit timeUnit) { FutureClusterResponses futureClusterResponses = execute(clusterRequest); try { clusterResponseCallback.callback(futureClusterResponses.get(timeout, timeUnit)); } catch (Exception e) { } }
public static <T> T manageSync(ClusterNode clusterNode, ManageAction<T> manageAction) throws Exception { ClusterGroup clusterGroup = ClusterGroupLocalServiceUtil.createClusterGroup(0); clusterGroup.setClusterNodeIds(clusterNode.getClusterNodeId()); FutureClusterResponses futureClusterResponses = manage(clusterGroup, manageAction); ClusterNodeResponses clusterNodeResponses = futureClusterResponses.get(); ClusterNodeResponse clusterNodeResponse = clusterNodeResponses.getClusterResponse(clusterNode); return (T) clusterNodeResponse.getResult(); }
public static Map<String, String> getClusterServerInfo(String clusterNodeId) throws Exception { List<ClusterNode> clusterNodes = ClusterExecutorUtil.getClusterNodes(); ClusterNode clusterNode = null; for (ClusterNode curClusterNode : clusterNodes) { String curClusterNodeId = curClusterNode.getClusterNodeId(); if (curClusterNodeId.equals(clusterNodeId)) { clusterNode = curClusterNode; break; } } if (clusterNode == null) { return null; } try { if (clusterNode.equals(ClusterExecutorUtil.getLocalClusterNode())) { return getServerInfo(); } ClusterRequest clusterRequest = ClusterRequest.createUnicastRequest(_getServerInfoMethodHandler, clusterNodeId); FutureClusterResponses futureClusterResponses = ClusterExecutorUtil.execute(clusterRequest); ClusterNodeResponses clusterNodeResponses = futureClusterResponses.get(20000, TimeUnit.MILLISECONDS); ClusterNodeResponse clusterNodeResponse = clusterNodeResponses.getClusterResponse(clusterNode); return (Map<String, String>) clusterNodeResponse.getResult(); } catch (Exception e) { _log.error(e, e); throw e; } }