Package com.ericsson.otp.erlang

Examples of com.ericsson.otp.erlang.OtpSelf


  private OtpPeer peer;

  // {'$gen_call', {To, Tag}, {call, Mod, Fun, Args, User}}
 
  public ErlangBeamDisLoader() throws OtpAuthException, IOException {
    self = new OtpSelf(myid);
    peer = new OtpPeer("beam_loader@localhost");
    conn = self.connect(peer);
  }
View Full Code Here


   *
   * @throws Exception
   */
  @Test(timeout = 4000)
  public void testServiceTimeouts() throws Exception {
    OtpSelf self = new OtpSelf("tmp_connector_"
        + System.currentTimeMillis());
    OtpPeer peer = new OtpPeer("RPCServerTimeout");
    OtpConnection connection = self.connect(peer);
    // delay message sending after connecting
    Thread.sleep(1000);
    // service binding timeout set to 500 so after that time it will give up
    // and close connection
    try {
      connection.send("rex", new OtpErlangString("test"));
      fail("Exception expected");
    } catch (Exception e) {
      assertEquals(IOException.class, e.getClass());
    }

    connection = self.connect(peer);
    // sending message immediately and encountering no connection close
    connection.send("rex", new OtpErlangString("test"));

  }
View Full Code Here

    }
    return msg;
  }

  private Message invokeOperation(Message msg) {
    OtpSelf self = null;
    OtpPeer other = null;
    OtpConnection connection = null;
    try {
      self = new OtpSelf(getClientNodeName());
      if (binding.hasCookie()) {
        self.setCookie(binding.getCookie());
      }
      other = new OtpPeer(binding.getNode());
      connection = self.connect(other);
      Method jmethod = ((JavaOperation) msg.getOperation())
          .getJavaMethod();
      OtpErlangList params = TypeHelpersProxy.toErlangAsList(msg
          .getBody(), jmethod.getParameterAnnotations());
      OtpErlangTuple message = MessageHelper.rpcMessage(self.pid(), self
          .createRef(), binding.getModule(), msg.getOperation()
          .getName(), params);
      connection.send(MessageHelper.RPC_MBOX, message);
      OtpErlangObject rpcResponse = null;
      if (binding.hasTimeout()) {
View Full Code Here

  private Map<String, List<Operation>> groupedOperations;

  public ErlangNode(String name, ErlangBinding binding,
      RuntimeComponentService service) throws Exception {
    this.name = name;
    self = new OtpSelf(name);
    boolean registered = self.publishPort();
    if (!registered) {
      // TODO: externalize message?
      throw new ErlangException(
          "Problem with publishing service under epmd server.");
View Full Code Here

   *
   * @throws Exception
   */
  @Test(timeout = 4000)
  public void testServiceTimeouts() throws Exception {
    OtpSelf self = new OtpSelf("tmp_connector_"
        + System.currentTimeMillis());
    OtpPeer peer = new OtpPeer("RPCServerTimeout");
    OtpConnection connection = self.connect(peer);
    // delay message sending after connecting
    Thread.sleep(1000);
    // service binding timeout set to 500 so after that time it will give up
    // and close connection
    try {
      connection.send("rex", new OtpErlangString("test"));
      fail("Exception expected");
    } catch (Exception e) {
      assertEquals(IOException.class, e.getClass());
    }

    connection = self.connect(peer);
    // sending message immediately and encountering no connection close
    connection.send("rex", new OtpErlangString("test"));

  }
View Full Code Here

            throws ConnectionException {
        if (clientNameAppendUUID) {
            clientName = clientName + "_" + clientNameUUID.getAndIncrement();
        }
        try {
            final OtpSelf self = new OtpSelf(clientName, cookie);
            return new Connection(self, connectionPolicy);
        } catch (final Exception e) {
//                 e.printStackTrace();
            throw new ConnectionException(e);
        }
View Full Code Here

     * @throws InterruptedException if the sleep is interrupted
     */
    @Test
    public final void testConnectionOtpSelfPeerNode() throws ConnectionException,
            OtpErlangExit, OtpAuthException, IOException, InterruptedException {
        final OtpSelf self = new OtpSelf("testConnection", ConnectionFactory
                .getInstance().getCookie());
        final PeerNode remote = new PeerNode(ConnectionFactory.getInstance()
                .getNodes().get(0).getNode().node());
        final Date d0 = new Date();
        TimeUnit.MILLISECONDS.sleep(10);
View Full Code Here

     * @throws InterruptedException if the sleep is interrupted
     */
    @Test
    public final void testConnectionOtpSelfConnectionPolicy() throws ConnectionException,
            OtpErlangExit, OtpAuthException, IOException, InterruptedException {
        final OtpSelf self = new OtpSelf("testConnection", ConnectionFactory
                .getInstance().getCookie());
        final PeerNode remote = new PeerNode(ConnectionFactory.getInstance()
                .getNodes().get(0).getNode().node());
        final Date d0 = new Date();
        TimeUnit.MILLISECONDS.sleep(10);
View Full Code Here

     *             occurs (should not happen)
     * @throws InterruptedException if the sleep is interrupted
     */
    @Test
    public final void testFailedConnection() throws IOException, InterruptedException {
        OtpSelf self;
        PeerNode remote;
        Connection c;
        DefaultConnectionPolicy connectionPolicy;
        final Date d0 = new Date();
        Date d1, d2;
        TimeUnit.MILLISECONDS.sleep(10);

        // wrong cookie:
        self = new OtpSelf("testFailedConnection",
                ConnectionFactory.getInstance().getCookie() + "someWrongCookieValue");
        remote = new PeerNode(ConnectionFactory.getInstance().getNodes().get(0).getNode().node());
        connectionPolicy = new DefaultConnectionPolicy(remote);
        connectionPolicy.setMaxRetries(0);
        try {
            c = new Connection(self, connectionPolicy);
            // this should have failed!
            fail();
            c.close();
        } catch (final Exception e) {
        }
        assertEquals(1, remote.getFailureCount());
        d1 = remote.getLastFailedConnect();
        assertNotNull(d1);
        assertTrue(d0.getTime() < d1.getTime());
        TimeUnit.MILLISECONDS.sleep(10);
        try {
            c = new Connection(self, connectionPolicy);
            // this should have failed!
            fail();
            c.close();
        } catch (final Exception e) {
        }
        assertEquals(2, remote.getFailureCount());
        d2 = remote.getLastFailedConnect();
        assertNotNull(d2);
        assertTrue(d0.getTime() < d2.getTime());
        assertTrue(d1.getTime() < d2.getTime());
        TimeUnit.MILLISECONDS.sleep(10);

        // unknown host name:
        self = new OtpSelf("testFailedConnection",
                ConnectionFactory.getInstance().getCookie());
        remote = new PeerNode(ConnectionFactory.getInstance().getNodes().get(0).getNode().node() + "noneExistingHost");
        connectionPolicy = new DefaultConnectionPolicy(remote);
        connectionPolicy.setMaxRetries(0);
        try {
            c = new Connection(self, connectionPolicy);
            // this should have failed!
            fail();
            c.close();
        } catch (final Exception e) {
        }
        assertEquals(1, remote.getFailureCount());
        d1 = remote.getLastFailedConnect();
        assertNotNull(d1);
        assertTrue(d0.getTime() < d1.getTime());
        TimeUnit.MILLISECONDS.sleep(10);
        try {
            c = new Connection(self, connectionPolicy);
            // this should have failed!
            fail();
            c.close();
        } catch (final Exception e) {
        }
        assertEquals(2, remote.getFailureCount());
        d2 = remote.getLastFailedConnect();
        assertNotNull(d2);
        assertTrue(d0.getTime() < d2.getTime());
        assertTrue(d1.getTime() < d2.getTime());
        TimeUnit.MILLISECONDS.sleep(10);

        // non-existing node name:
        self = new OtpSelf("testFailedConnection",
                ConnectionFactory.getInstance().getCookie());
        remote = new PeerNode("noneExistingNode" + ConnectionFactory.getInstance().getNodes().get(0).getNode().node());
        connectionPolicy = new DefaultConnectionPolicy(remote);
        connectionPolicy.setMaxRetries(0);
        try {
View Full Code Here

     */
    @Test
    public final void testDoRPCStringStringOtpErlangList()
            throws ConnectionException, OtpErlangExit, OtpAuthException,
            IOException, OtpErlangRangeException {
        final OtpSelf self = new OtpSelf("testDoRPCStringStringOtpErlangList",
                ConnectionFactory.getInstance().getCookie());
        final PeerNode remote = new PeerNode(ConnectionFactory.getInstance()
                .getNodes().get(0).getNode().node());
        final Connection c = new Connection(self, remote);

View Full Code Here

TOP

Related Classes of com.ericsson.otp.erlang.OtpSelf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.