/** Close all connections in the connection pool, and shutdown the worker thread pool. */ @Override public void close() { // Go through all clients and close them if they are active. for (ClientPool clientPool : connectionPool.values()) { for (int i = 0; i < clientPool.clients.length; i++) { TransportClient client = clientPool.clients[i]; if (client != null) { clientPool.clients[i] = null; JavaUtils.closeQuietly(client); } } } connectionPool.clear(); if (workerGroup != null) { workerGroup.shutdownGracefully(); workerGroup = null; } } }
/** Close all connections in the connection pool, and shutdown the worker thread pool. */ @Override public void close() { // Go through all clients and close them if they are active. for (ClientPool clientPool : connectionPool.values()) { for (int i = 0; i < clientPool.clients.length; i++) { TransportClient client = clientPool.clients[i]; if (client != null) { clientPool.clients[i] = null; JavaUtils.closeQuietly(client); } } } connectionPool.clear(); if (workerGroup != null) { workerGroup.shutdownGracefully(); workerGroup = null; } } }
/** Close all connections in the connection pool, and shutdown the worker thread pool. */ @Override public void close() { // Go through all clients and close them if they are active. for (ClientPool clientPool : connectionPool.values()) { for (int i = 0; i < clientPool.clients.length; i++) { TransportClient client = clientPool.clients[i]; if (client != null) { clientPool.clients[i] = null; JavaUtils.closeQuietly(client); } } } connectionPool.clear(); if (workerGroup != null) { workerGroup.shutdownGracefully(); workerGroup = null; } } }
/** Close all connections in the connection pool, and shutdown the worker thread pool. */ @Override public void close() { // Go through all clients and close them if they are active. for (ClientPool clientPool : connectionPool.values()) { for (int i = 0; i < clientPool.clients.length; i++) { TransportClient client = clientPool.clients[i]; if (client != null) { clientPool.clients[i] = null; JavaUtils.closeQuietly(client); } } } connectionPool.clear(); if (workerGroup != null) { workerGroup.shutdownGracefully(); workerGroup = null; } } }
@Override public InputStream createInputStream() throws IOException { FileInputStream is = null; try { is = new FileInputStream(file); ByteStreams.skipFully(is, offset); return new LimitedInputStream(is, length); } catch (IOException e) { try { if (is != null) { long size = file.length(); throw new IOException("Error in reading " + this + " (actual file length " + size + ")", e); } } catch (IOException ignored) { // ignore } finally { JavaUtils.closeQuietly(is); } throw new IOException("Error in opening " + this, e); } catch (RuntimeException e) { JavaUtils.closeQuietly(is); throw e; } }
@Override public InputStream createInputStream() throws IOException { FileInputStream is = null; try { is = new FileInputStream(file); ByteStreams.skipFully(is, offset); return new LimitedInputStream(is, length); } catch (IOException e) { try { if (is != null) { long size = file.length(); throw new IOException("Error in reading " + this + " (actual file length " + size + ")", e); } } catch (IOException ignored) { // ignore } finally { JavaUtils.closeQuietly(is); } throw new IOException("Error in opening " + this, e); } catch (RuntimeException e) { JavaUtils.closeQuietly(is); throw e; } }
@After public void tearDown() { JavaUtils.closeQuietly(server1); JavaUtils.closeQuietly(server2); }
@After public void tearDown() { JavaUtils.closeQuietly(server1); JavaUtils.closeQuietly(server2); }
JavaUtils.closeQuietly(channel);
@After public void tearDown() { if (clientFactory != null) { JavaUtils.closeQuietly(clientFactory); clientFactory = null; } if (server != null) { JavaUtils.closeQuietly(server); server = null; } }
JavaUtils.closeQuietly(channel);
JavaUtils.closeQuietly(channel);
JavaUtils.closeQuietly(channel);
@Override public InputStream createInputStream() throws IOException { FileInputStream is = null; boolean shouldClose = true; try { is = new FileInputStream(file); ByteStreams.skipFully(is, offset); InputStream r = new LimitedInputStream(is, length); shouldClose = false; return r; } catch (IOException e) { String errorMessage = "Error in reading " + this; if (is != null) { long size = file.length(); errorMessage = "Error in reading " + this + " (actual file length " + size + ")"; } throw new IOException(errorMessage, e); } finally { if (shouldClose) { JavaUtils.closeQuietly(is); } } }
@Override public InputStream createInputStream() throws IOException { FileInputStream is = null; boolean shouldClose = true; try { is = new FileInputStream(file); ByteStreams.skipFully(is, offset); InputStream r = new LimitedInputStream(is, length); shouldClose = false; return r; } catch (IOException e) { String errorMessage = "Error in reading " + this; if (is != null) { long size = file.length(); errorMessage = "Error in reading " + this + " (actual file length " + size + ")"; } throw new IOException(errorMessage, e); } finally { if (shouldClose) { JavaUtils.closeQuietly(is); } } }
/** * Creates a TransportServer that binds to the given host and the given port, or to any available * if 0. If you don't want to bind to any special host, set "hostToBind" to null. * */ public TransportServer( TransportContext context, String hostToBind, int portToBind, RpcHandler appRpcHandler, List<TransportServerBootstrap> bootstraps) { this.context = context; this.conf = context.getConf(); this.appRpcHandler = appRpcHandler; this.bootstraps = Lists.newArrayList(Preconditions.checkNotNull(bootstraps)); try { init(hostToBind, portToBind); } catch (RuntimeException e) { JavaUtils.closeQuietly(this); throw e; } }
/** * Creates a TransportServer that binds to the given host and the given port, or to any available * if 0. If you don't want to bind to any special host, set "hostToBind" to null. * */ public TransportServer( TransportContext context, String hostToBind, int portToBind, RpcHandler appRpcHandler, List<TransportServerBootstrap> bootstraps) { this.context = context; this.conf = context.getConf(); this.appRpcHandler = appRpcHandler; this.bootstraps = Lists.newArrayList(Preconditions.checkNotNull(bootstraps)); try { init(hostToBind, portToBind); } catch (RuntimeException e) { JavaUtils.closeQuietly(this); throw e; } }
/** * Creates a TransportServer that binds to the given host and the given port, or to any available * if 0. If you don't want to bind to any special host, set "hostToBind" to null. * */ public TransportServer( TransportContext context, String hostToBind, int portToBind, RpcHandler appRpcHandler, List<TransportServerBootstrap> bootstraps) { this.context = context; this.conf = context.getConf(); this.appRpcHandler = appRpcHandler; this.bootstraps = Lists.newArrayList(Preconditions.checkNotNull(bootstraps)); boolean shouldClose = true; try { init(hostToBind, portToBind); shouldClose = false; } finally { if (shouldClose) { JavaUtils.closeQuietly(this); } } }
/** * Creates a TransportServer that binds to the given host and the given port, or to any available * if 0. If you don't want to bind to any special host, set "hostToBind" to null. * */ public TransportServer( TransportContext context, String hostToBind, int portToBind, RpcHandler appRpcHandler, List<TransportServerBootstrap> bootstraps) { this.context = context; this.conf = context.getConf(); this.appRpcHandler = appRpcHandler; this.bootstraps = Lists.newArrayList(Preconditions.checkNotNull(bootstraps)); boolean shouldClose = true; try { init(hostToBind, portToBind); shouldClose = false; } finally { if (shouldClose) { JavaUtils.closeQuietly(this); } } }