use of com.google.cloud.aiplatform.v1.Endpoint in project wildfly-core by wildfly.
the class RemotingSubsystemAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
// WFCORE-4510 -- the effective endpoint configuration is from the root subsystem resource,
// not from the placeholder configuration=endpoint child resource.
ModelNode endpointModel = resource.getModel();
String workerName = WORKER.resolveModelAttribute(context, endpointModel).asString();
final OptionMap map = EndpointConfigFactory.populate(context, endpointModel);
// create endpoint
final String nodeName = WildFlySecurityManager.getPropertyPrivileged(RemotingExtension.NODE_NAME_PROPERTY, null);
// In case of a managed server the subsystem endpoint might already be installed {@see DomainServerCommunicationServices}
if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
final ServiceController<?> controller = context.getServiceRegistry(false).getService(RemotingServices.SUBSYSTEM_ENDPOINT);
if (controller != null) {
// if installed, just skip the rest
return;
}
}
final CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(REMOTING_ENDPOINT_CAPABILITY);
final Consumer<Endpoint> endpointConsumer = builder.provides(REMOTING_ENDPOINT_CAPABILITY);
final Supplier<XnioWorker> workerSupplier = builder.requiresCapability(IO_WORKER_CAPABILITY_NAME, XnioWorker.class, workerName);
builder.setInstance(new EndpointService(endpointConsumer, workerSupplier, nodeName, EndpointService.EndpointType.SUBSYSTEM, map));
builder.install();
}
use of com.google.cloud.aiplatform.v1.Endpoint in project wildfly-core by wildfly.
the class ManagementRemotingServices method installManagementChannelOpenListenerService.
/**
* Set up the services to create a channel listener. This assumes that an endpoint service called {@code endpointName} exists.
* @param serviceTarget the service target to install the services into
* @param endpointName the name of the endpoint to install a channel listener into
* @param channelName the name of the channel
* @param operationHandlerName the name of the operation handler to handle request for this channel
* @param options the remoting options
* @param onDemand whether to install the services on demand
*/
public static void installManagementChannelOpenListenerService(final ServiceTarget serviceTarget, final ServiceName endpointName, final String channelName, final ServiceName operationHandlerName, final OptionMap options, final boolean onDemand) {
final ServiceName serviceName = RemotingServices.channelServiceName(endpointName, channelName);
final ServiceBuilder<?> builder = serviceTarget.addService(serviceName);
final Supplier<ManagementChannelInitialization> ohfSupplier = builder.requires(operationHandlerName);
final Supplier<ExecutorService> esSupplier = builder.requires(SHUTDOWN_EXECUTOR_NAME);
final Supplier<Endpoint> eSupplier = builder.requires(endpointName);
final Supplier<ManagementChannelRegistryService> rSupplier = builder.requires(ManagementChannelRegistryService.SERVICE_NAME);
builder.setInstance(new ManagementChannelOpenListenerService(ohfSupplier, esSupplier, eSupplier, rSupplier, channelName, options));
builder.setInitialMode(onDemand ? ON_DEMAND : ACTIVE);
builder.install();
}
use of com.google.cloud.aiplatform.v1.Endpoint in project wildfly-core by wildfly.
the class ChannelServer method create.
public static ChannelServer create(final Configuration configuration) throws IOException {
checkNotNullParam("configuration", configuration).validate();
// Hack WFCORE-3302/REM3-303 workaround
if (firstCreate) {
firstCreate = false;
} else {
try {
// wait in case the previous socket has not closed
Thread.sleep(100);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
// TODO WFCORE-3302 -- Endpoint.getCurrent() should be ok
final Endpoint endpoint = Endpoint.builder().setEndpointName(configuration.getEndpointName()).build();
final NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface(configuration.getUriScheme(), NetworkServerProvider.class);
final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
final SimpleMapBackedSecurityRealm realm = new SimpleMapBackedSecurityRealm();
domainBuilder.addRealm("default", realm).build();
domainBuilder.setDefaultRealmName("default");
domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
SecurityDomain testDomain = domainBuilder.build();
SaslAuthenticationFactory saslAuthenticationFactory = SaslAuthenticationFactory.builder().setSecurityDomain(testDomain).setMechanismConfigurationSelector(mechanismInformation -> "ANONYMOUS".equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null).setFactory(new AnonymousServerFactory()).build();
System.out.println(configuration.getBindAddress());
AcceptingChannel<StreamConnection> streamServer = networkServerProvider.createServer(configuration.getBindAddress(), OptionMap.EMPTY, saslAuthenticationFactory, null);
return new ChannelServer(endpoint, null, streamServer);
}
use of com.google.cloud.aiplatform.v1.Endpoint in project wildfly-core by wildfly.
the class ProtocolConnectionUtils method connect.
private static IoFuture<Connection> connect(final CallbackHandler handler, final ProtocolConnectionConfiguration configuration) throws IOException {
configuration.validate();
final Endpoint endpoint = configuration.getEndpoint();
final URI uri = configuration.getUri();
String clientBindAddress = configuration.getClientBindAddress();
AuthenticationContext captured = AuthenticationContext.captureCurrent();
AuthenticationConfiguration mergedConfiguration = AUTH_CONFIGURATION_CLIENT.getAuthenticationConfiguration(uri, captured);
if (handler != null) {
if (configuration.isCallbackHandlerPreferred()) {
// Clear the three values as the CallbackHandler will be used for these.
mergedConfiguration = mergedConfiguration.useAnonymous();
mergedConfiguration = mergedConfiguration.useCredentials(IdentityCredentials.NONE);
mergedConfiguration = mergedConfiguration.useRealm(null);
}
mergedConfiguration = mergedConfiguration.useCallbackHandler(handler, DEFAULT_CALLBACK_KINDS);
}
Map<String, String> saslOptions = configuration.getSaslOptions();
mergedConfiguration = configureSaslMechanisms(saslOptions, isLocal(uri), mergedConfiguration);
// AuthenticationConfiguration will take precedence.
if (saslOptions != null) {
saslOptions = new HashMap<>(saslOptions);
// Drop SASL_DISALLOWED_MECHANISMS which we already handled
saslOptions.remove(Options.SASL_DISALLOWED_MECHANISMS.getName());
mergedConfiguration = mergedConfiguration.useMechanismProperties(saslOptions);
}
SSLContext sslContext = configuration.getSslContext();
if (sslContext == null) {
try {
sslContext = AUTH_CONFIGURATION_CLIENT.getSSLContext(uri, captured);
} catch (GeneralSecurityException e) {
throw ProtocolLogger.ROOT_LOGGER.failedToConnect(uri, e);
}
}
// WFCORE-2342 check for default SSL / TLS options
final OptionMap.Builder builder = OptionMap.builder();
OptionMap optionMap = configuration.getOptionMap();
for (Option option : optionMap) {
builder.set(option, optionMap.get(option));
}
if (optionMap.get(Options.SSL_ENABLED) == null)
builder.set(Options.SSL_ENABLED, configuration.isSslEnabled());
if (optionMap.get(Options.SSL_STARTTLS) == null)
builder.set(Options.SSL_STARTTLS, configuration.isUseStartTLS());
AuthenticationContext authenticationContext = AuthenticationContext.empty();
authenticationContext = authenticationContext.with(MatchRule.ALL, mergedConfiguration);
final SSLContext finalSslContext = sslContext;
authenticationContext = authenticationContext.withSsl(MatchRule.ALL, () -> finalSslContext);
if (clientBindAddress == null) {
return endpoint.connect(uri, builder.getMap(), authenticationContext);
} else {
InetSocketAddress bindAddr = new InetSocketAddress(clientBindAddress, 0);
return endpoint.connect(uri, bindAddr, builder.getMap(), authenticationContext);
}
}
use of com.google.cloud.aiplatform.v1.Endpoint in project java-aiplatform by googleapis.
the class EndpointServiceClientTest method listEndpointsTest.
@Test
public void listEndpointsTest() throws Exception {
Endpoint responsesElement = Endpoint.newBuilder().build();
ListEndpointsResponse expectedResponse = ListEndpointsResponse.newBuilder().setNextPageToken("").addAllEndpoints(Arrays.asList(responsesElement)).build();
mockEndpointService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListEndpointsPagedResponse pagedListResponse = client.listEndpoints(parent);
List<Endpoint> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEndpointsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockEndpointService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEndpointsRequest actualRequest = ((ListEndpointsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations