public RemoteNamingProvider createProvider(final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) throws NamingException { return new RemoteNamingProvider(getEndpoint(env), providerEnvironment, env); }
RemoteClientTransport getRemoteTransport(ConnectionPeerIdentity peerIdentity) throws NamingException { final Endpoint endpoint = provider.getEndpoint(); if (endpoint == null) { throw Messages.log.noRemotingEndpoint(); } try { final Connection connection = peerIdentity.getConnection(); final IoFuture<RemoteClientTransport> future = RemoteClientTransport.SERVICE_HANDLE.getClientService(connection, OptionMap.EMPTY); try { return future.getInterruptibly(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); future.cancel(); throw Messages.log.operationInterrupted(); } } catch (IOException e) { if (e.getCause() instanceof NamingException) { throw (NamingException) e.getCause(); } throw Messages.log.connectFailed(e); } }
/** * Get the connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the connection peer identity (not {@code null}) * @throws AuthenticationException if authenticating or re-authenticating the peer failed * @throws IOException if connecting the peer failed */ public ConnectionPeerIdentity getPeerIdentity(final URI location) throws IOException { Assert.checkNotNullParam("location", location); return getFuturePeerIdentity(location).get(); }
protected void unbindNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).unbind(name_, peerIdentity); return null; }, environment, context, realName, null); }
/** * Get the future connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the future connection peer identity (not {@code null}) */ public IoFuture<ConnectionPeerIdentity> getFuturePeerIdentity(final URI location) { return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> getFuturePeerIdentityPrivileged(location)); }
/** * Get the connection peer identity for a naming operation. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the connection peer identity (not {@code null}) * @throws NamingException if connecting, authenticating, or re-authenticating the peer failed */ public ConnectionPeerIdentity getPeerIdentityForNaming(final URI location) throws NamingException { Assert.checkNotNullParam("location", location); try { return getPeerIdentity(location); } catch (AuthenticationException e) { throw Messages.log.authenticationFailed(e); } catch (IOException e) { throw Messages.log.connectFailed(e); } }
private <T, R> R performWithRetry(NamingOperation<T, R> function, ProviderEnvironment environment, RetryContext context, Name name, T param) throws NamingException { return provider.performExceptionAction(function, context, name, param); R result = provider.performExceptionAction(function, context, name, param); environment.dropFromBlacklist(context.currentDestination()); return result;
protected CloseableNamingEnumeration<NameClassPair> listNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; return performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); return getRemoteTransport(peerIdentity).list(name_, peerIdentity); }, environment, context, realName, null); }
/** * Get the future connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the future connection peer identity (not {@code null}) */ public IoFuture<ConnectionPeerIdentity> getFuturePeerIdentity(final URI location) { return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> getFuturePeerIdentityPrivileged(location)); }
/** * Get the connection peer identity for a naming operation. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the connection peer identity (not {@code null}) * @throws NamingException if connecting, authenticating, or re-authenticating the peer failed */ public ConnectionPeerIdentity getPeerIdentityForNaming(final URI location) throws NamingException { Assert.checkNotNullParam("location", location); try { return getPeerIdentity(location); } catch (AuthenticationException e) { throw Messages.log.authenticationFailed(e); } catch (IOException e) { throw Messages.log.connectFailed(e); } }
private <T, R> R performWithRetry(NamingOperation<T, R> function, ProviderEnvironment environment, RetryContext context, Name name, T param) throws NamingException { return provider.performExceptionAction(function, context, name, param); R result = provider.performExceptionAction(function, context, name, param); environment.dropFromBlacklist(context.currentDestination()); return result;
protected void destroySubcontextNative(final Name name) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, name_, ignored) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).destroySubcontext(name_, peerIdentity); return null; }, environment, context, realName, null); }
/** * Get the future connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the future connection peer identity (not {@code null}) */ public IoFuture<ConnectionPeerIdentity> getFuturePeerIdentity(final URI location) { return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> getFuturePeerIdentityPrivileged(location)); }
/** * Get the connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the connection peer identity (not {@code null}) * @throws AuthenticationException if authenticating or re-authenticating the peer failed * @throws IOException if connecting the peer failed */ public ConnectionPeerIdentity getPeerIdentity(final URI location) throws IOException { Assert.checkNotNullParam("location", location); return getFuturePeerIdentity(location).get(); }
public RemoteNamingProvider createProvider(final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) throws NamingException { return new RemoteNamingProvider(getEndpoint(env), providerEnvironment, env); }
/** * Get the connection peer identity for a naming operation. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the connection peer identity (not {@code null}) * @throws NamingException if connecting, authenticating, or re-authenticating the peer failed */ public ConnectionPeerIdentity getPeerIdentityForNaming(final URI location) throws NamingException { Assert.checkNotNullParam("location", location); try { return getPeerIdentity(location); } catch (AuthenticationException e) { throw Messages.log.authenticationFailed(e); } catch (IOException e) { throw Messages.log.connectFailed(e); } }
RemoteClientTransport getRemoteTransport(ConnectionPeerIdentity peerIdentity) throws NamingException { final Endpoint endpoint = provider.getEndpoint(); if (endpoint == null) { throw Messages.log.noRemotingEndpoint(); } try { final Connection connection = peerIdentity.getConnection(); final IoFuture<RemoteClientTransport> future = RemoteClientTransport.SERVICE_HANDLE.getClientService(connection, OptionMap.EMPTY); try { return future.getInterruptibly(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); future.cancel(); throw Messages.log.operationInterrupted(); } } catch (IOException e) { if (e.getCause() instanceof NamingException) { throw (NamingException) e.getCause(); } throw Messages.log.connectFailed(e); } }
private <T, R> R performWithRetry(NamingOperation<T, R> function, ProviderEnvironment environment, RetryContext context, Name name, T param) throws NamingException { return provider.performExceptionAction(function, context, name, param); R result = provider.performExceptionAction(function, context, name, param); environment.dropFromBlacklist(context.currentDestination()); return result;
protected void rebindNative(final Name name, final Object obj) throws NamingException { Name realName = getRealName(name); ProviderEnvironment environment = provider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; performWithRetry((context_, name_, obj_) -> { final ConnectionPeerIdentity peerIdentity = provider.getPeerIdentityForNamingUsingRetry(context_); getRemoteTransport(peerIdentity).bind(name_, obj_, peerIdentity, true); return null; }, environment, context, realName, obj); }
/** * Get the connection peer identity. If the connection is not configured as {@code immediate}, then the connection * will not actually be established until this method is called. The resultant connection should be closed and * discarded in the event of an error, in order to facilitate automatic reconnection. * * @param location a location from {@link ProviderEnvironment#getProviderUris()} (must not be {@code null}) * @return the connection peer identity (not {@code null}) * @throws AuthenticationException if authenticating or re-authenticating the peer failed * @throws IOException if connecting the peer failed */ public ConnectionPeerIdentity getPeerIdentity(final URI location) throws IOException { Assert.checkNotNullParam("location", location); return getFuturePeerIdentity(location).get(); }