use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.
the class RemoteChannelPairSetup method setupRemoting.
public void setupRemoting(final ManagementChannelInitialization initialization) throws IOException {
// executorService = Executors.newCachedThreadPool();
final ThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("Remoting"), Boolean.FALSE, null, "Remoting %f thread %t", null, null);
executorService = new QueueExecutor(EXECUTOR_MAX_THREADS / 4 + 1, EXECUTOR_MAX_THREADS, EXECUTOR_KEEP_ALIVE_TIME, TimeUnit.MILLISECONDS, 500, threadFactory, true, null);
final ChannelServer.Configuration configuration = new ChannelServer.Configuration();
configuration.setEndpointName(ENDPOINT_NAME);
configuration.setUriScheme(URI_SCHEME);
configuration.setBindAddress(new InetSocketAddress("127.0.0.1", PORT));
configuration.setExecutor(executorService);
channelServer = ChannelServer.create(configuration);
channelServer.addChannelOpenListener(TEST_CHANNEL, new OpenListener() {
@Override
public void registrationTerminated() {
}
@Override
public void channelOpened(Channel channel) {
serverChannel = channel;
initialization.startReceiving(channel);
clientConnectedLatch.countDown();
}
});
}
use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.
the class DomainLifecycleUtil method executeAwaitConnectionClosed.
/**
* Execute an operation and wait until the connection is closed. This is only useful for :reload and :shutdown operations.
*
* @param operation the operation to execute
* @return the operation result
* @throws IOException for any error
* @throws IllegalStateException if {@link #close()} has previously been invoked on this instance.
*/
public ModelNode executeAwaitConnectionClosed(final ModelNode operation) throws IOException {
checkClosed();
final DomainTestClient client = internalGetOrCreateClient();
final Channel channel = client.getChannel();
if (null == channel) {
throw new IllegalStateException("Didn't get a remoting channel from the DomainTestClient.");
}
final Connection ref = channel.getConnection();
ModelNode result = new ModelNode();
try {
result = client.execute(operation);
// IN case the operation wasn't successful, don't bother waiting
if (!"success".equals(result.get("outcome").asString())) {
return result;
}
} catch (IOException e) {
final Throwable cause = e.getCause();
if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException)) {
throw e;
}
// else ignore, this might happen if the channel gets closed before we got the response
}
try {
// Wait for the channel to close
channel.awaitClosed();
// Wait for the connection to be closed
connection.awaitConnectionClosed(ref);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return result;
}
use of com.google.cloud.video.livestream.v1.Channel in project kubernetes-client by fabric8io.
the class ChannelTest method get.
@Test
void get() {
// Given
server.expect().get().withPath("/apis/apps.open-cluster-management.io/v1/namespaces/ns1/channels/test-get").andReturn(HttpURLConnection.HTTP_OK, createNewChannel("test-get")).once();
// When
Channel channel = client.apps().channels().inNamespace("ns1").withName("test-get").get();
// Then
assertThat(channel).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "test-get");
}
use of com.google.cloud.video.livestream.v1.Channel in project solarnetwork-node by SolarNetwork.
the class MasterDemo method run.
static void run(DNP3Manager manager) throws Exception {
// Create a tcp channel class that will connect to the loopback
Channel channel = manager.addTCPClient("client", LogMasks.NORMAL | LogMasks.APP_COMMS, ChannelRetry.getDefault(), "127.0.0.1", "0.0.0.0", 20000, new Slf4jChannelListener());
// You can modify the defaults to change the way the master behaves
MasterStackConfig config = new MasterStackConfig();
// Create a master instance, pass in a simple singleton to print received values to the console
Master master = channel.addMaster("master", PrintingSOEHandler.getInstance(), DefaultMasterApplication.getInstance(), config);
// do an integrity scan every 2 seconds
// master.addPeriodicScan(Duration.ofSeconds(2), Header.getIntegrity());
master.enable();
// all this cruft just to read a line of text in Java. Oh the humanity.
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
while (true) {
System.out.println("Enter something to issue a command or type <quit> to exit");
String line = in.readLine();
switch(line) {
case ("quit"):
return;
case ("crob"):
ControlRelayOutputBlock crob = new ControlRelayOutputBlock(ControlCode.LATCH_ON, (short) 1, 100, 100, CommandStatus.SUCCESS);
master.selectAndOperateCROB(crob, 0).thenAccept(// asynchronously print the result of the command operation
(CommandTaskResult result) -> System.out.println(result));
break;
case ("scan"):
master.scan(Header.getEventClasses());
break;
default:
System.out.println("Unknown command: " + line);
break;
}
}
}
use of com.google.cloud.video.livestream.v1.Channel in project solarnetwork-node by SolarNetwork.
the class OutstationService method createOutstation.
private Outstation createOutstation() {
Channel channel = channel();
if (channel == null) {
log.info("DNP3 channel not available for outstation [{}]", getUid());
return null;
}
log.info("Initializing DNP3 outstation [{}]", getUid());
try {
return channel.addOutstation(getUid(), commandHandler, app, createOutstationStackConfig());
} catch (DNP3Exception e) {
log.error("Error creating outstation application [{}]: {}", getUid(), e.getMessage(), e);
return null;
}
}
Aggregations