@Test public void testRedirect() throws Exception { dir1.sendRedirectTo = "localhost:" + PORT_DIR2; DIRClient client = new DIRClient(testEnv.getDirClient(), servers, 10, 2); AddressMappingSet result = client.xtreemfs_address_mappings_get(null, RPCAuthentication.authNone, RPCAuthentication.userService, "*"); assertEquals(0, result.getMappingsCount()); }
protected void redirect(PBRPCException exception) throws InterruptedException { assert (exception.getErrorType() == ErrorType.REDIRECT); final String address = exception.getRedirectToServerUUID(); try { final int colon = address.indexOf(':'); final String hostname = address.substring(0, colon); final String portStr = address.substring(colon + 1); final int port = Integer.valueOf(portStr); final InetSocketAddress redirectTo = new InetSocketAddress(hostname, port); for (int i = 0; i < servers.length; i++) { final InetSocketAddress server = servers[i]; if (server.equals(redirectTo)) { Logging.logMessage(Logging.LEVEL_DEBUG, Logging.Category.net, this, "redirected to DIR: %s", server); synchronized (this) { currentServer = i; } if (redirectedBefore) { Thread.sleep(retryWaitMs); } else { redirectedBefore = true; } return; } } throw new IOException("Cannot redirect to unknown server: " + redirectTo); } catch (InterruptedException ex) { throw ex; } catch (Exception ex) { Logging.logError(Logging.LEVEL_ERROR, this, ex); } }
DIRClient implements TimeServerClient { protected void redirect(PBRPCException exception) throws InterruptedException { assert (exception.getErrorType() == ErrorType.REDIRECT); final String address = exception.getRedirectToServerUUID(); try { final int colon = address.indexOf(':'); final String hostname = address.substring(0, colon); final String portStr = address.substring(colon + 1); final int port = Integer.valueOf(portStr); final InetSocketAddress redirectTo = new InetSocketAddress(hostname, port); for (int i = 0; i < servers.length; i++) { final InetSocketAddress server = servers[i]; if (server.equals(redirectTo)) { Logging.logMessage(Logging.LEVEL_DEBUG, Logging.Category.net, this, "redirected to DIR: %s", server); synchronized (this) { currentServer = i; } if (redirectedBefore) { Thread.sleep(retryWaitMs); } else { redirectedBefore = true; } return; } } throw new IOException("Cannot redirect to unknown server: " + redirectTo); } catch (InterruptedException ex) { throw ex; } catch (Exception ex) { Logging.logError(Logging.LEVEL_ERROR, this, ex); } } }
DIRClient implements TimeServerClient { protected void redirect(PBRPCException exception) throws InterruptedException { assert (exception.getErrorType() == ErrorType.REDIRECT); final String address = exception.getRedirectToServerUUID(); try { final int colon = address.indexOf(':'); final String hostname = address.substring(0, colon); final String portStr = address.substring(colon + 1); final int port = Integer.valueOf(portStr); final InetSocketAddress redirectTo = new InetSocketAddress(hostname, port); for (int i = 0; i < servers.length; i++) { final InetSocketAddress server = servers[i]; if (server.equals(redirectTo)) { Logging.logMessage(Logging.LEVEL_DEBUG, Logging.Category.net, this, "redirected to DIR: %s", server); synchronized (this) { currentServer = i; } if (redirectedBefore) { Thread.sleep(retryWaitMs); } else { redirectedBefore = true; } return; } } throw new IOException("Cannot redirect to unknown server: " + redirectTo); } catch (InterruptedException ex) { throw ex; } catch (Exception ex) { Logging.logError(Logging.LEVEL_ERROR, this, ex); } } DIRClient(DIRServiceClient rpcClient, InetSocketAddress[] servers, int maxRetries, int retryWaitMs); }
DIRClient implements TimeServerClient { protected void redirect(PBRPCException exception) throws InterruptedException { assert (exception.getErrorType() == ErrorType.REDIRECT); final String address = exception.getRedirectToServerUUID(); try { final int colon = address.indexOf(':'); final String hostname = address.substring(0, colon); final String portStr = address.substring(colon + 1); final int port = Integer.valueOf(portStr); final InetSocketAddress redirectTo = new InetSocketAddress(hostname, port); for (int i = 0; i < servers.length; i++) { final InetSocketAddress server = servers[i]; if (server.equals(redirectTo)) { Logging.logMessage(Logging.LEVEL_DEBUG, Logging.Category.net, this, "redirected to DIR: %s", server); synchronized (this) { currentServer = i; } if (redirectedBefore) { Thread.sleep(retryWaitMs); } else { redirectedBefore = true; } return; } } throw new IOException("Cannot redirect to unknown server: " + redirectTo); } catch (InterruptedException ex) { throw ex; } catch (Exception ex) { Logging.logError(Logging.LEVEL_ERROR, this, ex); } } DIRClient(DIRServiceClient rpcClient, InetSocketAddress[] servers, int maxRetries, int retryWaitMs); AddressMappingSet xtreemfs_address_mappings_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); AddressMappingSet xtreemfs_address_mappings_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); void xtreemfs_address_mappings_remove(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); void xtreemfs_address_mappings_remove(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final List<AddressMapping> mappings); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final List<AddressMapping> mappings, int maxRetries); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final AddressMappingSet input); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final AddressMappingSet input, int maxRetries); void xtreemfs_service_deregister(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); void xtreemfs_service_deregister(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); void xtreemfs_service_offline(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name); void xtreemfs_service_offline(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name, int maxRetries); ServiceSet xtreemfs_service_get_by_name(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name); ServiceSet xtreemfs_service_get_by_name(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name, int maxRetries); ServiceSet xtreemfs_service_get_by_uuid(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); ServiceSet xtreemfs_service_get_by_uuid(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); ServiceSet xtreemfs_service_get_by_type(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final ServiceType type); ServiceSet xtreemfs_service_get_by_type(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final ServiceType type, int maxRetries); serviceRegisterResponse xtreemfs_service_register(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Service service); serviceRegisterResponse xtreemfs_service_register(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Service service, int maxRetries); Configuration xtreemfs_configuration_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); Configuration xtreemfs_configuration_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); configurationSetResponse xtreemfs_configuration_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Configuration config); configurationSetResponse xtreemfs_configuration_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Configuration config, int maxRetries); @Override long xtreemfs_global_time_get(InetSocketAddress server); long xtreemfs_global_time_get(); boolean clientIsAlive(); }
DIRClient implements TimeServerClient { protected void redirect(PBRPCException exception) throws InterruptedException { assert (exception.getErrorType() == ErrorType.REDIRECT); final String address = exception.getRedirectToServerUUID(); try { final int colon = address.indexOf(':'); final String hostname = address.substring(0, colon); final String portStr = address.substring(colon + 1); final int port = Integer.valueOf(portStr); final InetSocketAddress redirectTo = new InetSocketAddress(hostname, port); for (int i = 0; i < servers.length; i++) { final InetSocketAddress server = servers[i]; if (server.equals(redirectTo)) { Logging.logMessage(Logging.LEVEL_DEBUG, Logging.Category.net, this, "redirected to DIR: %s", server); synchronized (this) { currentServer = i; } if (redirectedBefore) { Thread.sleep(retryWaitMs); } else { redirectedBefore = true; } return; } } throw new IOException("Cannot redirect to unknown server: " + redirectTo); } catch (InterruptedException ex) { throw ex; } catch (Exception ex) { Logging.logError(Logging.LEVEL_ERROR, this, ex); } } DIRClient(DIRServiceClient rpcClient, InetSocketAddress[] servers, int maxRetries, int retryWaitMs); AddressMappingSet xtreemfs_address_mappings_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); AddressMappingSet xtreemfs_address_mappings_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); void xtreemfs_address_mappings_remove(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); void xtreemfs_address_mappings_remove(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final List<AddressMapping> mappings); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final List<AddressMapping> mappings, int maxRetries); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final AddressMappingSet input); addressMappingSetResponse xtreemfs_address_mappings_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final AddressMappingSet input, int maxRetries); void xtreemfs_service_deregister(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); void xtreemfs_service_deregister(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); void xtreemfs_service_offline(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name); void xtreemfs_service_offline(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name, int maxRetries); ServiceSet xtreemfs_service_get_by_name(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name); ServiceSet xtreemfs_service_get_by_name(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String name, int maxRetries); ServiceSet xtreemfs_service_get_by_uuid(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); ServiceSet xtreemfs_service_get_by_uuid(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); ServiceSet xtreemfs_service_get_by_type(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final ServiceType type); ServiceSet xtreemfs_service_get_by_type(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final ServiceType type, int maxRetries); serviceRegisterResponse xtreemfs_service_register(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Service service); serviceRegisterResponse xtreemfs_service_register(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Service service, int maxRetries); Configuration xtreemfs_configuration_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid); Configuration xtreemfs_configuration_get(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final String uuid, int maxRetries); configurationSetResponse xtreemfs_configuration_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Configuration config); configurationSetResponse xtreemfs_configuration_set(InetSocketAddress server, final Auth authHeader,
            final UserCredentials userCreds, final Configuration config, int maxRetries); @Override long xtreemfs_global_time_get(InetSocketAddress server); long xtreemfs_global_time_get(); boolean clientIsAlive();  }