/** * Create a 'smarter' HConnection, one that is capable of by-passing RPC if the request is to * the local server. Safe to use going to local or remote server. * Create this instance in a method can be intercepted and mocked in tests. * * @throws IOException */ @VisibleForTesting protected ClusterConnection createClusterConnection() throws IOException { // Create a cluster connection that when appropriate, can short-circuit and go directly to the // local server if the request is to the local server bypassing RPC. Can be used for both local // and remote invocations. return ConnectionUtils .createShortCircuitConnection(conf, null, userProvider.getCurrent(), serverName, rpcServices, rpcServices); }
/** * Create a 'smarter' HConnection, one that is capable of by-passing RPC if the request is to * the local server. Safe to use going to local or remote server. * Create this instance in a method can be intercepted and mocked in tests. * * @throws IOException */ @VisibleForTesting protected ClusterConnection createClusterConnection() throws IOException { // Create a cluster connection that when appropriate, can short-circuit and go directly to the // local server if the request is to the local server bypassing RPC. Can be used for both local // and remote invocations. return ConnectionUtils.createShortCircuitHConnection( ConnectionFactory.createConnection(conf), serverName, rpcServices, rpcServices); }
/** * Create a 'smarter' Connection, one that is capable of by-passing RPC if the request is to * the local server; i.e. a short-circuit Connection. Safe to use going to local or remote * server. Create this instance in a method can be intercepted and mocked in tests. * @throws IOException */ @VisibleForTesting protected ClusterConnection createClusterConnection() throws IOException { // Create a cluster connection that when appropriate, can short-circuit and go directly to the // local server if the request is to the local server bypassing RPC. Can be used for both local // and remote invocations. return ConnectionUtils.createShortCircuitConnection(conf, null, userProvider.getCurrent(), serverName, rpcServices, rpcServices); }
public static void main(String...args) throws Exception { long timeWaited = 0l; for (int i = 1; i <= 40; i++) { timeWaited += ConnectionUtils.getPauseTime(90, i); } System.out.printf("timeWaited: %d sec%n", timeWaited); }
@Override public Connection createConnection(Configuration conf) throws IOException { User user = UserProvider.instantiate(conf).getCurrent(); return ConnectionUtils.createShortCircuitConnection(conf, null, user, this.serverName, this.rpcServices, this.rpcServices); }
static void sleepIgnoreInterrupt(int retry) { try { Thread.sleep(ConnectionUtils.getPauseTime(100, retry)); } catch (InterruptedException e) { } }
private static void checkShortCircuit(Connection connection) { assertTrue(connection instanceof ConnectionUtils.ShortCircuitingClusterConnection); }
/** * Create CatalogTracker. * In its own method so can intercept and mock it over in tests. * @throws IOException */ protected CatalogTracker createCatalogTracker() throws IOException { HConnection conn = ConnectionUtils.createShortCircuitHConnection( HConnectionManager.getConnection(conf), serverName, rpcServices, rpcServices); return new CatalogTracker(zooKeeper, conf, conn, this); }