use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.
the class AbstractChannelOpenListenerService method channelOpened.
@Override
public void channelOpened(Channel channel) {
// this should be using the graceful shutdown control
if (closed) {
RemotingLogger.ROOT_LOGGER.debugf("server shutting down, closing channel %s.", channel);
channel.closeAsync();
return;
}
final ManagementChannelShutdownHandle handle = handleChannelOpened(channel);
trackerService.registerTracker(handle);
handles.add(handle);
channel.addCloseHandler(new CloseHandler<Channel>() {
public void handleClose(final Channel closed, final IOException exception) {
handles.remove(handle);
handle.shutdownNow();
trackerService.unregisterTracker(handle);
RemotingLogger.ROOT_LOGGER.tracef("Handling close for %s", handle);
}
});
}
use of com.automatak.dnp3.Channel in project wildfly-core by wildfly.
the class ManagementChannelHandler method getRemoteAddress.
/**
* Get the remote address.
*
* @return the remote address, {@code null} if not available
*/
public InetAddress getRemoteAddress() {
final Channel channel;
try {
channel = strategy.getChannel();
} catch (IOException e) {
return null;
}
final Connection connection = channel.getConnection();
final InetSocketAddress peerAddress = connection.getPeerAddress(InetSocketAddress.class);
return peerAddress == null ? null : peerAddress.getAddress();
}
use of com.automatak.dnp3.Channel in project kubernetes-client by fabric8io.
the class ChannelTest method builderShouldCreateObject.
@Test
void builderShouldCreateObject() {
// Given
ChannelBuilder channelBuilder = new ChannelBuilder().withNewMetadata().addToLabels("vendor", "OpenShift").withName("sample-channel").endMetadata().withNewSpec().withType("HelmRepo").withPathname("https://charts.helm.sh/stable").withNewConfigMapRef().withKind("ConfigMap").withName("test-configmap").endConfigMapRef().endSpec();
// When
Channel channel = channelBuilder.build();
// Then
assertNotNull(channel);
assertEquals("sample-channel", channel.getMetadata().getName());
assertEquals(1, channel.getMetadata().getLabels().size());
assertEquals("HelmRepo", channel.getSpec().getType());
assertEquals("https://charts.helm.sh/stable", channel.getSpec().getPathname());
assertEquals("test-configmap", channel.getSpec().getConfigMapRef().getName());
assertEquals("ConfigMap", channel.getSpec().getConfigMapRef().getKind());
}
use of com.automatak.dnp3.Channel in project kubernetes-client by fabric8io.
the class ChannelTest method deserializationAndSerializationShouldWorkAsExpected.
@Test
void deserializationAndSerializationShouldWorkAsExpected() throws IOException {
// Given
String originalJson = new Scanner(getClass().getResourceAsStream("/valid-channel.json")).useDelimiter("\\A").next();
// When
final Channel channel = mapper.readValue(originalJson, Channel.class);
final String serializedJson = mapper.writeValueAsString(channel);
final Channel apiRequestCountFromSerializedJson = mapper.readValue(serializedJson, Channel.class);
// Then
assertNotNull(channel);
assertNotNull(serializedJson);
assertNotNull(apiRequestCountFromSerializedJson);
assertEquals(channel.getMetadata().getName(), apiRequestCountFromSerializedJson.getMetadata().getName());
assertEquals("HelmRepo", channel.getSpec().getType());
assertEquals("https://charts.helm.sh/stable", channel.getSpec().getPathname());
assertEquals("bookinfo-resource-filter-configmap", channel.getSpec().getConfigMapRef().getName());
assertEquals("configmap", channel.getSpec().getConfigMapRef().getKind());
}
use of com.automatak.dnp3.Channel in project solarnetwork-node by SolarNetwork.
the class OutstationDemo method run.
public static void run(DNP3Manager manager) throws Exception {
// Create a tcp channel class that will connect to the loopback
Channel channel = manager.addTCPServer("client", LogMasks.NORMAL | LogMasks.APP_COMMS, ServerAcceptMode.CloseNew, "127.0.0.1", 20000, new Slf4jChannelListener());
// Create the default outstation configuration
OutstationStackConfig config = new OutstationStackConfig(DatabaseConfig.allValues(5), EventBufferConfig.allTypes(50));
// Create an Outstation instance, pass in a simple a command handler that responds successfully to everything
Outstation outstation = channel.addOutstation("outstation", SuccessCommandHandler.getInstance(), DefaultOutstationApplication.getInstance(), config);
outstation.enable();
// all this stuff just to read a line of text in Java. Oh the humanity.
String line = "";
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
int i = 0;
while (true) {
System.out.println("Enter something to update a counter or type <quit> to exit");
line = in.readLine();
if (line.equals("quit"))
break;
else {
OutstationChangeSet set = new OutstationChangeSet();
set.update(new Counter(i, (byte) 0x01, 0), 0);
outstation.apply(set);
++i;
}
}
}
Aggregations