use of com.google.cloud.aiplatform.v1.Endpoint in project jboss-remoting by jboss-remoting.
the class HeartbeatTestCase method testDisableHeartbeat.
/**
* Test that heartbeat can be set and can be disabled by setting it to 0
*
* @throws Exception
*/
@Test
public void testDisableHeartbeat() throws Exception {
Channel clientChannel = null;
Channel serverChannel = null;
Closeable streamServer = null;
Connection connection = null;
Registration serviceRegistration = null;
final Endpoint endpoint = Endpoint.builder().setEndpointName("test").build();
NetworkServerProvider networkServerProvider = endpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class);
final SecurityDomain.Builder domainBuilder = SecurityDomain.builder();
final SimpleMapBackedSecurityRealm mainRealm = new SimpleMapBackedSecurityRealm();
domainBuilder.addRealm("mainRealm", mainRealm).build();
domainBuilder.setDefaultRealmName("mainRealm");
domainBuilder.setPermissionMapper((permissionMappable, roles) -> PermissionVerifier.ALL);
final PasswordFactory passwordFactory = PasswordFactory.getInstance("clear");
mainRealm.setPasswordMap("bob", passwordFactory.generatePassword(new ClearPasswordSpec("pass".toCharArray())));
final SaslServerFactory saslServerFactory = new ServiceLoaderSaslServerFactory(HeartbeatTestCase.class.getClassLoader());
final SaslAuthenticationFactory.Builder builder = SaslAuthenticationFactory.builder();
builder.setSecurityDomain(domainBuilder.build());
builder.setFactory(saslServerFactory);
builder.setMechanismConfigurationSelector(mechanismInformation -> SaslMechanismInformation.Names.SCRAM_SHA_256.equals(mechanismInformation.getMechanismName()) ? MechanismConfiguration.EMPTY : null);
final SaslAuthenticationFactory saslAuthenticationFactory = builder.build();
streamServer = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE), saslAuthenticationFactory, SSLContext.getDefault());
final FutureResult<Channel> passer = new FutureResult<Channel>();
serviceRegistration = endpoint.registerService("org.jboss.test", new OpenListener() {
public void channelOpened(final Channel channel) {
passer.setResult(channel);
}
public void registrationTerminated() {
}
}, OptionMap.EMPTY);
IoFuture<Connection> futureConnection = AuthenticationContext.empty().with(MatchRule.ALL, AuthenticationConfiguration.empty().useName("bob").usePassword("pass").setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism("SCRAM-SHA-256"))).run(new PrivilegedAction<IoFuture<Connection>>() {
public IoFuture<Connection> run() {
try {
return endpoint.connect(new URI("remote://localhost:30123"), OptionMap.create(RemotingOptions.HEARTBEAT_INTERVAL, 0));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
});
connection = futureConnection.get();
IoFuture<Channel> futureChannel = connection.openChannel("org.jboss.test", OptionMap.EMPTY);
clientChannel = futureChannel.get();
serverChannel = passer.getIoFuture().get();
assertNotNull(serverChannel);
RemoteConnectionChannel remoteClientChannel = (RemoteConnectionChannel) clientChannel;
assertEquals(0, Utils.getInstanceValue(remoteClientChannel.getRemoteConnection(), "heartbeatInterval"));
RemoteWriteListener clientWriteListener = (RemoteWriteListener) Utils.getInstanceValue(remoteClientChannel.getRemoteConnection(), "writeListener");
assertNull(Utils.getInstanceValue(clientWriteListener, "heartKey"));
afterTest(clientChannel, serverChannel, connection, serviceRegistration);
destroy(endpoint, streamServer);
}
use of com.google.cloud.aiplatform.v1.Endpoint in project jboss-ejb-client by wildfly.
the class RemotingLegacyConfiguration method getConfiguredEndpoint.
public Endpoint getConfiguredEndpoint() {
final JBossEJBProperties properties = JBossEJBProperties.getCurrent();
if (properties == null) {
return null;
}
Logs.MAIN.legacyEJBPropertiesRemotingConfigurationInUse();
final EndpointBuilder endpointBuilder = Endpoint.builder();
final String endpointName = properties.getEndpointName();
if (endpointName != null) {
endpointBuilder.setEndpointName(endpointName);
}
OptionMap endpointCreationOptions = properties.getEndpointCreationOptions();
if (endpointCreationOptions != null && endpointCreationOptions.size() > 0) {
if (!endpointCreationOptions.contains(Options.THREAD_DAEMON)) {
endpointCreationOptions = OptionMap.builder().addAll(endpointCreationOptions).set(Options.THREAD_DAEMON, true).getMap();
}
endpointBuilder.buildXnioWorker(Xnio.getInstance()).populateFromOptions(endpointCreationOptions);
}
final List<JBossEJBProperties.ConnectionConfiguration> connectionList = properties.getConnectionList();
List<URI> uris = new ArrayList<URI>();
for (JBossEJBProperties.ConnectionConfiguration connectionConfiguration : connectionList) {
final OptionMap connectionOptions = connectionConfiguration.getConnectionOptions();
final URI uri = CommonLegacyConfiguration.getUri(connectionConfiguration, connectionOptions);
if (uri == null) {
continue;
}
if (connectionConfiguration.isConnectEagerly()) {
uris.add(uri);
}
final ConnectionBuilder connectionBuilder = endpointBuilder.addConnection(uri);
connectionBuilder.setHeartbeatInterval(connectionOptions.get(RemotingOptions.HEARTBEAT_INTERVAL, RemotingOptions.DEFAULT_HEARTBEAT_INTERVAL));
if (connectionOptions.get(Options.READ_TIMEOUT, -1) != -1) {
connectionBuilder.setReadTimeout(connectionOptions.get(Options.READ_TIMEOUT, -1));
}
if (connectionOptions.get(Options.WRITE_TIMEOUT, -1) != -1) {
connectionBuilder.setWriteTimeout(connectionOptions.get(Options.WRITE_TIMEOUT, -1));
}
connectionBuilder.setTcpKeepAlive(connectionOptions.get(Options.KEEP_ALIVE, false));
}
final Endpoint endpoint;
try {
endpoint = endpointBuilder.build();
} catch (IOException e) {
throw Logs.MAIN.failedToConstructEndpoint(e);
}
for (URI uri : uris) {
endpoint.getConnection(uri, "ejb", "jboss");
}
return endpoint;
}
use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.
the class V2SpanWriter method endpointSizeInBytes.
static int endpointSizeInBytes(Endpoint value, boolean writeEmptyServiceName) {
// {
int sizeInBytes = 1;
String serviceName = value.serviceName();
if (serviceName == null && writeEmptyServiceName)
serviceName = "";
if (serviceName != null) {
// "serviceName":""
sizeInBytes += 16;
sizeInBytes += jsonEscapedSizeInBytes(serviceName);
}
if (value.ipv4() != null) {
// ,
if (sizeInBytes != 1)
sizeInBytes++;
// "ipv4":""
sizeInBytes += 9;
sizeInBytes += value.ipv4().length();
}
if (value.ipv6() != null) {
// ,
if (sizeInBytes != 1)
sizeInBytes++;
// "ipv6":""
sizeInBytes += 9;
sizeInBytes += value.ipv6().length();
}
int port = value.portAsInt();
if (port != 0) {
// ,
if (sizeInBytes != 1)
sizeInBytes++;
// "port":
sizeInBytes += 7;
sizeInBytes += asciiSizeInBytes(port);
}
// }
return ++sizeInBytes;
}
use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.
the class V1BinaryAnnotation method hashCode.
@Override
public int hashCode() {
int h = 1;
h *= 1000003;
h ^= key.hashCode();
h *= 1000003;
h ^= stringValue == null ? 0 : stringValue.hashCode();
h *= 1000003;
h ^= endpoint == null ? 0 : endpoint.hashCode();
return h;
}
use of com.google.cloud.aiplatform.v1.Endpoint in project zipkin by openzipkin.
the class JacksonSpanDecoder method parseEndpoint.
static Endpoint parseEndpoint(JsonParser jsonParser) throws IOException {
if (!jsonParser.isExpectedStartObjectToken()) {
throw new IOException("Not a valid JSON object, start token: " + jsonParser.currentToken());
}
String serviceName = null, ipv4 = null, ipv6 = null;
int port = 0;
while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
String fieldName = jsonParser.currentName();
JsonToken value = jsonParser.nextToken();
if (value == JsonToken.VALUE_NULL) {
continue;
}
switch(fieldName) {
case "serviceName":
serviceName = jsonParser.getValueAsString();
break;
case "ipv4":
ipv4 = jsonParser.getValueAsString();
break;
case "ipv6":
ipv6 = jsonParser.getValueAsString();
break;
case "port":
port = jsonParser.getValueAsInt();
break;
default:
jsonParser.skipChildren();
}
}
if (serviceName == null && ipv4 == null && ipv6 == null && port == 0)
return null;
return Endpoint.newBuilder().serviceName(serviceName).ip(ipv4).ip(ipv6).port(port).build();
}
Aggregations