use of org.eclipse.milo.opcua.sdk.server.nodes.AttributeObserver in project milo by eclipse.
the class SessionDiagnosticsVariable method onStartup.
@Override
protected void onStartup() {
ServerDiagnosticsTypeNode diagnosticsNode = (ServerDiagnosticsTypeNode) server.getAddressSpaceManager().getManagedNode(Identifiers.Server_ServerDiagnostics).orElseThrow(() -> new NoSuchElementException("NodeId: " + Identifiers.Server_ServerDiagnostics));
diagnosticsEnabled.set(diagnosticsNode.getEnabledFlag());
attributeObserver = (node, attributeId, value) -> {
if (attributeId == AttributeId.Value) {
DataValue dataValue = (DataValue) value;
Object o = dataValue.getValue().getValue();
if (o instanceof Boolean) {
diagnosticsEnabled.set((Boolean) o);
}
}
};
diagnosticsNode.getEnabledFlagNode().addAttributeObserver(attributeObserver);
node.getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject xo = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getSessionDiagnosticsDataType());
return new DataValue(new Variant(xo));
}));
node.getSessionIdNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
NodeId value = session.getSessionDiagnostics().getSessionId();
return new DataValue(new Variant(value));
}));
node.getSessionNameNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
String value = session.getSessionDiagnostics().getSessionName();
return new DataValue(new Variant(value));
}));
node.getClientDescriptionNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getClientDescription());
return new DataValue(new Variant(value));
}));
node.getServerUriNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
String value = session.getSessionDiagnostics().getServerUri();
return new DataValue(new Variant(value));
}));
node.getEndpointUrlNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
String value = session.getSessionDiagnostics().getEndpointUrl();
return new DataValue(new Variant(value));
}));
node.getLocaleIdsNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
String[] value = session.getSessionDiagnostics().getLocaleIds();
return new DataValue(new Variant(value));
}));
node.getActualSessionTimeoutNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
Double value = session.getSessionDiagnostics().getActualSessionTimeout();
return new DataValue(new Variant(value));
}));
node.getMaxResponseMessageSizeNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = session.getSessionDiagnostics().getMaxResponseMessageSize();
return new DataValue(new Variant(value));
}));
node.getClientConnectionTimeNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
DateTime value = session.getSessionDiagnostics().getClientConnectionTime();
return new DataValue(new Variant(value));
}));
node.getClientLastContactTimeNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
DateTime value = session.getSessionDiagnostics().getClientLastContactTime();
return new DataValue(new Variant(value));
}));
node.getCurrentSubscriptionsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = session.getSessionDiagnostics().getCurrentSubscriptionsCount();
return new DataValue(new Variant(value));
}));
node.getCurrentMonitoredItemsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = session.getSessionDiagnostics().getCurrentMonitoredItemsCount();
return new DataValue(new Variant(value));
}));
node.getCurrentPublishRequestsInQueueNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = session.getSessionDiagnostics().getCurrentPublishRequestsInQueue();
return new DataValue(new Variant(value));
}));
node.getTotalRequestCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getTotalRequestCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getUnauthorizedRequestCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(session.getSessionDiagnostics().getUnauthorizedRequestCount().longValue());
return new DataValue(new Variant(value));
}));
node.getReadCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getReadCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getHistoryReadCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getHistoryReadCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getWriteCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getWriteCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getHistoryUpdateCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getHistoryUpdateCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getCallCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getCallCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getCreateMonitoredItemsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getCreateMonitoredItemsCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getModifyMonitoredItemsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getModifyMonitoredItemsCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getSetMonitoringModeCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getSetMonitoringModeCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getSetTriggeringCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getSetTriggeringCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getDeleteMonitoredItemsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getDeleteMonitoredItemsCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getCreateSubscriptionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getCreateSubscriptionCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getModifySubscriptionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getModifySubscriptionCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getSetPublishingModeCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getSetPublishingModeCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getPublishCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getPublishCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getRepublishCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getRepublishCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getTransferSubscriptionsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getTransferSubscriptionsCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getDeleteSubscriptionsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getDeleteSubscriptionsCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getAddNodesCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getAddNodesCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getAddReferencesCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getAddReferencesCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getDeleteNodesCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getDeleteNodesCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getDeleteReferencesCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getDeleteReferencesCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getBrowseCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getBrowseCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getBrowseNextCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getBrowseNextCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getTranslateBrowsePathsToNodeIdsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getTranslateBrowsePathsToNodeIdsCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getQueryFirstCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getQueryFirstCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getQueryNextCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getQueryNextCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getRegisterNodesCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getRegisterNodesCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
node.getUnregisterNodesCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject value = ExtensionObject.encode(server.getSerializationContext(), session.getSessionDiagnostics().getUnregisterNodesCount().getServiceCounter());
return new DataValue(new Variant(value));
}));
}
use of org.eclipse.milo.opcua.sdk.server.nodes.AttributeObserver in project milo by eclipse.
the class ServerDiagnosticsSummaryVariable method onStartup.
@Override
protected void onStartup() {
ServerDiagnosticsTypeNode diagnosticsNode = (ServerDiagnosticsTypeNode) server.getAddressSpaceManager().getManagedNode(Identifiers.Server_ServerDiagnostics).orElseThrow(() -> new NoSuchElementException("NodeId: " + Identifiers.Server_ServerDiagnostics));
diagnosticsEnabled.set(diagnosticsNode.getEnabledFlag());
attributeObserver = (node, attributeId, value) -> {
if (attributeId == AttributeId.Value) {
DataValue dataValue = (DataValue) value;
Object o = dataValue.getValue().getValue();
if (o instanceof Boolean) {
diagnosticsEnabled.set((Boolean) o);
}
}
};
diagnosticsNode.getEnabledFlagNode().addAttributeObserver(attributeObserver);
node.getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject xo = ExtensionObject.encode(server.getSerializationContext(), server.getDiagnosticsSummary().getServerDiagnosticsSummaryDataType());
return new DataValue(new Variant(xo));
}));
node.getServerViewCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getCurrentViewCount().longValue());
return new DataValue(new Variant(value));
}));
node.getCurrentSessionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getCurrentSessionCount().longValue());
return new DataValue(new Variant(value));
}));
node.getCumulatedSessionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getCumulatedSessionCount().longValue());
return new DataValue(new Variant(value));
}));
node.getSecurityRejectedSessionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getSecurityRejectedSessionCount().longValue());
return new DataValue(new Variant(value));
}));
node.getRejectedSessionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getRejectedSessionCount().longValue());
return new DataValue(new Variant(value));
}));
node.getSessionTimeoutCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getSessionTimeoutCount().longValue());
return new DataValue(new Variant(value));
}));
node.getSessionAbortCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getSessionAbortCount().longValue());
return new DataValue(new Variant(value));
}));
node.getPublishingIntervalCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getPublishingIntervalCount().longValue());
return new DataValue(new Variant(value));
}));
node.getCurrentSubscriptionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getCurrentSubscriptionCount().longValue());
return new DataValue(new Variant(value));
}));
node.getCumulatedSubscriptionCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = uint(server.getDiagnosticsSummary().getCumulatedSubscriptionCount().longValue());
return new DataValue(new Variant(value));
}));
node.getSecurityRejectedRequestsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = server.getDiagnosticsSummary().getSecurityRejectedRequestCount();
return new DataValue(new Variant(value));
}));
node.getRejectedRequestsCountNode().getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
UInteger value = server.getDiagnosticsSummary().getRejectedRequestCount();
return new DataValue(new Variant(value));
}));
}
use of org.eclipse.milo.opcua.sdk.server.nodes.AttributeObserver in project milo by eclipse.
the class SessionDiagnosticsVariableArray method onShutdown.
@Override
protected void onShutdown() {
AttributeObserver observer = attributeObserver;
if (observer != null) {
ServerDiagnosticsTypeNode diagnosticsNode = (ServerDiagnosticsTypeNode) server.getAddressSpaceManager().getManagedNode(Identifiers.Server_ServerDiagnostics).orElseThrow(() -> new NoSuchElementException("NodeId: " + Identifiers.Server_ServerDiagnostics));
diagnosticsNode.getEnabledFlagNode().removeAttributeObserver(observer);
attributeObserver = null;
}
if (sessionListener != null) {
server.getSessionManager().removeSessionListener(sessionListener);
sessionListener = null;
}
sessionDiagnosticsVariables.forEach(Lifecycle::shutdown);
sessionDiagnosticsVariables.clear();
node.delete();
}
use of org.eclipse.milo.opcua.sdk.server.nodes.AttributeObserver in project milo by eclipse.
the class SessionDiagnosticsVariableArray method onStartup.
@Override
protected void onStartup() {
ServerDiagnosticsTypeNode diagnosticsNode = (ServerDiagnosticsTypeNode) server.getAddressSpaceManager().getManagedNode(Identifiers.Server_ServerDiagnostics).orElseThrow(() -> new NoSuchElementException("NodeId: " + Identifiers.Server_ServerDiagnostics));
diagnosticsEnabled.set(diagnosticsNode.getEnabledFlag());
if (diagnosticsEnabled.get()) {
addSessionListener();
}
attributeObserver = (node, attributeId, value) -> {
if (attributeId == AttributeId.Value) {
DataValue dataValue = (DataValue) value;
Object o = dataValue.getValue().getValue();
if (o instanceof Boolean) {
boolean current = (boolean) o;
boolean previous = diagnosticsEnabled.getAndSet(current);
if (!previous && current) {
server.getSessionManager().getAllSessions().forEach(this::createSessionDiagnosticsVariable);
if (sessionListener == null) {
addSessionListener();
}
} else if (previous && !current) {
if (sessionListener != null) {
server.getSessionManager().removeSessionListener(sessionListener);
sessionListener = null;
}
sessionDiagnosticsVariables.forEach(Lifecycle::shutdown);
sessionDiagnosticsVariables.clear();
}
}
}
};
diagnosticsNode.getEnabledFlagNode().addAttributeObserver(attributeObserver);
node.getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject[] xos = ExtensionObject.encodeArray(server.getSerializationContext(), server.getSessionManager().getAllSessions().stream().map(s -> s.getSessionDiagnostics().getSessionDiagnosticsDataType()).toArray(SessionDiagnosticsDataType[]::new));
return new DataValue(new Variant(xos));
}));
}
use of org.eclipse.milo.opcua.sdk.server.nodes.AttributeObserver in project milo by eclipse.
the class SessionSecurityDiagnosticsVariableArray method onStartup.
@Override
protected void onStartup() {
ServerDiagnosticsTypeNode diagnosticsNode = (ServerDiagnosticsTypeNode) server.getAddressSpaceManager().getManagedNode(Identifiers.Server_ServerDiagnostics).orElseThrow(() -> new NoSuchElementException("NodeId: " + Identifiers.Server_ServerDiagnostics));
diagnosticsEnabled.set(diagnosticsNode.getEnabledFlag());
if (diagnosticsEnabled.get()) {
addSessionListener();
}
attributeObserver = (node, attributeId, value) -> {
if (attributeId == AttributeId.Value) {
DataValue dataValue = (DataValue) value;
Object o = dataValue.getValue().getValue();
if (o instanceof Boolean) {
boolean current = (boolean) o;
boolean previous = diagnosticsEnabled.getAndSet(current);
if (!previous && current) {
server.getSessionManager().getAllSessions().forEach(this::createSessionSecurityDiagnosticsVariable);
if (sessionListener == null) {
addSessionListener();
}
} else if (previous && !current) {
if (sessionListener != null) {
server.getSessionManager().removeSessionListener(sessionListener);
sessionListener = null;
}
sessionSecurityDiagnosticsVariables.forEach(Lifecycle::shutdown);
sessionSecurityDiagnosticsVariables.clear();
}
}
}
};
diagnosticsNode.getEnabledFlagNode().addAttributeObserver(attributeObserver);
node.getFilterChain().addLast(diagnosticValueFilter(diagnosticsEnabled, ctx -> {
ExtensionObject[] xos = ExtensionObject.encodeArray(server.getSerializationContext(), server.getSessionManager().getAllSessions().stream().map(s -> s.getSessionSecurityDiagnostics().getSessionSecurityDiagnosticsDataType()).toArray(SessionSecurityDiagnosticsDataType[]::new));
return new DataValue(new Variant(xos));
}));
}
Aggregations