Tabnine Logo
NettyTransceiver
Code IndexAdd Tabnine to your IDE (free)

How to use
NettyTransceiver
in
org.apache.avro.ipc

Best Java code snippets using org.apache.avro.ipc.NettyTransceiver (Showing top 20 results out of 315)

origin: apache/avro

protected static Transceiver initializeTransceiver(int serverPort) throws IOException {
 return new NettyTransceiver(new InetSocketAddress(
   serverPort), CONNECT_TIMEOUT_MILLIS);
}
origin: apache/avro

/**
 * Closes this transceiver and disconnects from the remote peer.
 * Cancels all pending RPCs, sends an IOException to all pending callbacks,
 * and blocks until the close has completed.
 */
@Override
public void close() {
 close(true);
}
origin: apache/avro

/**
 * Creates a NettyTransceiver, and attempts to connect to the given address.
 * {@link #DEFAULT_CONNECTION_TIMEOUT_MILLIS} is used for the connection
 * timeout.
 * @param addr the address to connect to.
 * @param channelFactory the factory to use to create a new Netty Channel.
 * @throws IOException if an error occurs connecting to the given address.
 */
public NettyTransceiver(InetSocketAddress addr, ChannelFactory channelFactory)
 throws IOException {
 this(addr, channelFactory, buildDefaultBootstrapOptions(null));
}
origin: apache/avro

final NettyTransceiver transceiver = new NettyTransceiver(new InetSocketAddress(serverPort), 60000L);
final Mail mail = SpecificRequestor.getClient(Mail.class, transceiver);
quitOnFailure.set(true);
now = System.currentTimeMillis();
transceiver.close(); // Without the patch, this close seems to hang forever
origin: apache/avro

 @Override
 public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p = Channels.pipeline();
  p.addLast("frameDecoder", new NettyFrameDecoder());
  p.addLast("frameEncoder", new NettyFrameEncoder());
  p.addLast("handler", createNettyClientAvroHandler());
  return p;
 }
});
origin: gauravrmazra/gauravbytes

  public static void main(String[] args) throws IOException {
    if (args.length != 3) {
      System.out.println("Usage: <to> <from> <body>");
      System.exit(1);
    }

    logger.info("Starting Server");
    // usually this would be another app, but for simplicity
    startServer();
    logger.info("Server started");

    NettyTransceiver client = new NettyTransceiver(new InetSocketAddress(65333));
    // client code - attach to the server and send a message
    EmailSender proxy = SpecificRequestor.getClient(EmailSender.class, client);
    logger.info("Client built, got proxy");

    // fill in the Message record and send it
    EmailMessage message = new EmailMessage();
    message.setTo(new Utf8(args[0]));
    message.setFrom(new Utf8(args[1]));
    message.setBody(new Utf8(args[2]));
    logger.info("Calling proxy.send with message: {} ", message.toString());
    logger.info("Result: {}", proxy.send(message));
    // cleanup
    client.close();
    server.close();
  }
}
origin: org.apache.avro/avro-ipc

 @Override
 public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p = Channels.pipeline();
  p.addLast("frameDecoder", new NettyFrameDecoder());
  p.addLast("frameEncoder", new NettyFrameEncoder());
  p.addLast("handler", createNettyClientAvroHandler());
  return p;
 }
});
origin: apache/avro

@Override
public Transceiver createTransceiver() throws Exception{
 return new NettyTransceiver(new InetSocketAddress(server.getPort()), 2000L);
}
origin: org.apache.avro/avro-ipc

/**
 * Closes this transceiver and disconnects from the remote peer.
 * Cancels all pending RPCs, sends an IOException to all pending callbacks,
 * and blocks until the close has completed.
 */
@Override
public void close() {
 close(true);
}
origin: apache/avro

/**
 * Creates a NettyTransceiver, and attempts to connect to the given address.
 * @param addr the address to connect to.
 * @param channelFactory the factory to use to create a new Netty Channel.
 * @param connectTimeoutMillis maximum amount of time to wait for connection
 * establishment in milliseconds, or null to use
 * {@link #DEFAULT_CONNECTION_TIMEOUT_MILLIS}.
 * @throws IOException if an error occurs connecting to the given address.
 */
public NettyTransceiver(InetSocketAddress addr, ChannelFactory channelFactory,
  Long connectTimeoutMillis) throws IOException {
 this(addr, channelFactory,
   buildDefaultBootstrapOptions(connectTimeoutMillis));
}
origin: apache/avro

protected static Transceiver initializeTransceiver(int serverPort) throws IOException {
 return  new NettyTransceiver(new InetSocketAddress(serverPort),
   new SSLChannelFactory(),
   CONNECT_TIMEOUT_MILLIS);
}
origin: org.deeplearning4j/cdh4

nettyTransceiver.close();
updateExecutor.shutdownNow();
origin: org.apache.avro/avro-ipc

/**
 * Creates a NettyTransceiver, and attempts to connect to the given address.
 * {@link #DEFAULT_CONNECTION_TIMEOUT_MILLIS} is used for the connection
 * timeout.
 * @param addr the address to connect to.
 * @param channelFactory the factory to use to create a new Netty Channel.
 * @throws IOException if an error occurs connecting to the given address.
 */
public NettyTransceiver(InetSocketAddress addr, ChannelFactory channelFactory)
 throws IOException {
 this(addr, channelFactory, buildDefaultBootstrapOptions(null));
}
origin: apache/avro

protected static Transceiver initializeTransceiver(int serverPort) throws IOException {
 return  new NettyTransceiver(new InetSocketAddress(serverPort),
   new CompressionChannelFactory(),
   CONNECT_TIMEOUT_MILLIS);
}
origin: org.apache.avro/avro-ipc

/**
 * Creates a NettyTransceiver, and attempts to connect to the given address.
 * @param addr the address to connect to.
 * @param channelFactory the factory to use to create a new Netty Channel.
 * @param connectTimeoutMillis maximum amount of time to wait for connection
 * establishment in milliseconds, or null to use
 * {@link #DEFAULT_CONNECTION_TIMEOUT_MILLIS}.
 * @throws IOException if an error occurs connecting to the given address.
 */
public NettyTransceiver(InetSocketAddress addr, ChannelFactory channelFactory,
  Long connectTimeoutMillis) throws IOException {
 this(addr, channelFactory,
   buildDefaultBootstrapOptions(connectTimeoutMillis));
}
origin: apache/avro

@BeforeClass
public static void initializeConnections() throws Exception {
 // start server
 Responder responder = new SpecificResponder(Simple.class, simpleService);
 server = new NettyServer(responder, new InetSocketAddress(0));
 server.start();
 int serverPort = server.getPort();
 System.out.println("server port : " + serverPort);
 transceiver = new NettyTransceiver(new InetSocketAddress(
   serverPort), TestNettyServer.CONNECT_TIMEOUT_MILLIS);
 simpleClient = SpecificRequestor.getClient(Simple.Callback.class, transceiver);
}
origin: apache/flume

transceiver = new NettyTransceiver(this.address,
  socketChannelFactory,
  tu.toMillis(timeout));
origin: apache/avro

@Test(expected = IOException.class)
public void testNettyTransceiverReleasesNettyChannelOnFailingToConnect() throws Exception {
  ServerSocket serverSocket = null;
  LastChannelRememberingChannelFactory socketChannelFactory = null;
  try {
    serverSocket = new ServerSocket(0);
    socketChannelFactory = new LastChannelRememberingChannelFactory();
    try {
      new NettyTransceiver(
          new InetSocketAddress(serverSocket.getLocalPort()),
          socketChannelFactory,
          1L
      );
    } finally {
      assertEquals("expected that the channel opened by the transceiver is closed",
          false, socketChannelFactory.lastChannel.isOpen());
    }
  } finally {
    if (serverSocket != null) {
      // closing the server socket will actually free up the open channel in the
      // transceiver, which would have hung otherwise (pre AVRO-1407)
      serverSocket.close();
    }
    if (socketChannelFactory != null) {
      socketChannelFactory.releaseExternalResources();
    }
  }
}
origin: apache/avro

System.out.println("server2 port : " + serverPort);
transceiver2 = new NettyTransceiver(new InetSocketAddress(
  serverPort), TestNettyServer.CONNECT_TIMEOUT_MILLIS);
origin: apache/avro

@Test
public void testConnectionsCount() throws Exception {
 Transceiver transceiver2 = new NettyTransceiver(new InetSocketAddress(
     server.getPort()), CONNECT_TIMEOUT_MILLIS);
 Mail proxy2 = SpecificRequestor.getClient(Mail.class, transceiver2);
 proxy.fireandforget(createMessage());
 proxy2.fireandforget(createMessage());
 Assert.assertEquals(2, ((NettyServer) server).getNumActiveConnections());
 transceiver2.close();
 // Check the active connections with some retries as closing at the client
 // side might not take effect on the server side immediately
 int numActiveConnections = ((NettyServer) server).getNumActiveConnections();
 for (int i = 0; i < 50 && numActiveConnections == 2; ++i) {
  System.out.println("Server still has 2 active connections; retrying...");
  Thread.sleep(100);
  numActiveConnections = ((NettyServer) server).getNumActiveConnections();
 }
 Assert.assertEquals(1, numActiveConnections);
}
org.apache.avro.ipcNettyTransceiver

Javadoc

A Netty-based Transceiver implementation.

Most used methods

  • <init>
    Creates a NettyTransceiver, and attempts to connect to the given address. It is strongly recommended
  • close
    Closes this transceiver and disconnects from the remote peer. Cancels all pending RPCs and sends an
  • buildDefaultBootstrapOptions
    Creates the default options map for the Netty ClientBootstrap.
  • createNettyClientAvroHandler
    Creates a Netty ChannelUpstreamHandler for handling events on the Netty client channel.
  • disconnect
    Closes the connection to the remote peer if connected.
  • getChannel
    Gets the Netty channel. If the channel is not connected, first attempts to connect. NOTE: The stateL
  • isChannelReady
    Tests whether the given channel is ready for writing.
  • transceive
  • writeDataPack
    Writes a NettyDataPack, reconnecting to the remote peer if necessary. NOTE: The stateLock read lock

Popular in Java

  • Creating JSON documents from java classes using gson
  • onRequestPermissionsResult (Fragment)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • runOnUiThread (Activity)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Runner (org.openjdk.jmh.runner)
  • Option (scala)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now