Exemplo n.º 1
0
 private void tryConnect() throws RpcException {
   synchronized (connectLock) {
     switch (state) {
       case DISCONNECTED:
         reported = false;
         if (connectRetry()) {
           state = State.CONNECTED;
         } else if (connectOnce) {
           state = State.DOWN;
         } else {
           state = State.DISCONNECTED;
         }
         break;
       case CONNECTED:
         break;
       case DOWN:
         try {
           if (process != null) {
             process.terminate();
           }
         } catch (final DebugException e) {
           ErlLogger.info(e);
         }
         // TODO restart it??
         // process =
         if (!stopped) {
           final String msg = reportRuntimeDown(data.getNodeName());
           throw new RpcException(msg);
         }
     }
   }
 }
Exemplo n.º 2
0
 @Override
 public OtpErlangObject call(
     final int timeout,
     final OtpErlangObject gleader,
     final String module,
     final String fun,
     final String signature,
     final Object... args0)
     throws RpcException {
   if (stopped) {
     return null;
   }
   tryConnect();
   OtpErlangObject result;
   try {
     result =
         rpcHelper.rpcCall(
             localNode,
             data.getNodeName(),
             false,
             gleader,
             module,
             fun,
             timeout,
             signature,
             args0);
   } catch (final SignatureException e) {
     throw new RpcException(e);
   }
   return result;
 }
Exemplo n.º 3
0
 @Override
 public void send(final String name, final Object msg) {
   try {
     tryConnect();
     rpcHelper.send(localNode, data.getNodeName(), name, msg);
   } catch (final SignatureException e) {
   } catch (final RpcException e) {
   }
 }
Exemplo n.º 4
0
 @Override
 public void cast(
     final OtpErlangObject gleader,
     final String module,
     final String fun,
     final String signature,
     final Object... args0)
     throws RpcException {
   tryConnect();
   try {
     rpcHelper.rpcCast(
         localNode, data.getNodeName(), false, gleader, module, fun, signature, args0);
   } catch (final SignatureException e) {
     throw new RpcException(e);
   }
 }
Exemplo n.º 5
0
 @Override
 public void async_call_result(
     final IRpcResultCallback cb,
     final String m,
     final String f,
     final String signature,
     final Object... args)
     throws RpcException {
   final OtpErlangAtom gleader = new OtpErlangAtom("user");
   try {
     rpcHelper.rpcCastWithProgress(
         cb, localNode, data.getNodeName(), false, gleader, m, f, signature, args);
   } catch (final SignatureException e) {
     throw new RpcException(e);
   }
 }
Exemplo n.º 6
0
 @Override
 public void async_call_cb(
     final IRpcCallback cb,
     final int timeout,
     final OtpErlangObject gleader,
     final String module,
     final String fun,
     final String signature,
     final Object... args)
     throws RpcException {
   tryConnect();
   try {
     rpcHelper.makeAsyncCbCall(
         localNode, data.getNodeName(), cb, timeout, gleader, module, fun, signature, args);
   } catch (final SignatureException e) {
     throw new RpcException(e);
   }
 }
Exemplo n.º 7
0
 @Override
 public String getNodeName() {
   return data.getNodeName();
 }