nstream.reflect.MetaWarpDownlink Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nstream-reflect Show documentation
Show all versions of nstream-reflect Show documentation
Web Agent introspection runtime
The newest version!
// Copyright 2015-2024 Nstream, inc.
//
// Licensed under the Redis Source Available License 2.0 (RSALv2) Agreement;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://redis.com/legal/rsalv2-agreement/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package nstream.reflect;
import nstream.reflect.agent.MetaWarpDownlinkAgent;
import nstream.reflect.model.LinkStats;
import nstream.reflect.model.LogEntry;
import swim.system.NodeBinding;
import swim.system.Push;
import swim.system.WarpBinding;
import swim.system.WarpProxy;
import swim.uri.UriPath;
import swim.warp.Envelope;
public final class MetaWarpDownlink extends WarpProxy implements MetaLink {
MetaCell parent;
final MetaWarpDownlinkAgent agent;
public MetaWarpDownlink(MetaCell parent, WarpBinding linkBinding) {
super(linkBinding);
this.parent = parent;
this.agent = new MetaWarpDownlinkAgent(this);
}
@Override
public MetaCell metaParent() {
return this.parent;
}
@Override
public MetaWarpDownlinkAgent metaAgent() {
return this.agent;
}
@Override
public LinkStats linkStats() {
return this.agent.linkStats();
}
@Override
public void pushDown(Push> push) {
super.pushDown(push);
final Object message = push.message();
if (message instanceof Envelope) {
this.agent.didPushDown((Envelope) message);
}
}
@Override
public void pushUp(Push> push) {
super.pushUp(push);
final Object message = push.message();
if (message instanceof Envelope) {
this.agent.didPushUp((Envelope) message);
}
}
@Override
public void traceDown(Object message) {
this.agent.didLogTrace(LogEntry.trace(nodeUri(), laneUri(), message));
}
@Override
public void debugDown(Object message) {
this.agent.didLogDebug(LogEntry.debug(nodeUri(), laneUri(), message));
}
@Override
public void infoDown(Object message) {
this.agent.didLogInfo(LogEntry.info(nodeUri(), laneUri(), message));
}
@Override
public void warnDown(Object message) {
this.agent.didLogWarn(LogEntry.warn(nodeUri(), laneUri(), message));
}
@Override
public void errorDown(Object message) {
this.agent.didLogError(LogEntry.error(nodeUri(), laneUri(), message));
}
@Override
public void traceUp(Object message) {
this.agent.didLogTrace(LogEntry.trace(nodeUri(), laneUri(), message));
}
@Override
public void debugUp(Object message) {
this.agent.didLogDebug(LogEntry.debug(nodeUri(), laneUri(), message));
}
@Override
public void infoUp(Object message) {
this.agent.didLogInfo(LogEntry.info(nodeUri(), laneUri(), message));
}
@Override
public void warnUp(Object message) {
this.agent.didLogWarn(LogEntry.warn(nodeUri(), laneUri(), message));
}
@Override
public void errorUp(Object message) {
this.agent.didLogError(LogEntry.error(nodeUri(), laneUri(), message));
}
@Override
public void didFail(Throwable error) {
try {
this.agent.didLogFail(LogEntry.fail(nodeUri(), laneUri(), error));
} finally {
super.didFail(error);
}
}
@Override
public void didOpenDown() {
super.didOpenDown();
didOpen();
}
protected void didOpen() {
this.agent.didOpenDownlink(this);
}
@Override
public void didCloseDown() {
didClose();
super.didCloseDown();
}
@Override
public void didCloseUp() {
didClose();
super.didCloseUp();
}
protected void didClose() {
this.agent.didCloseDownlink(this);
this.agent.close();
}
public NodeBinding resolveMetaDownlink(UriPath nodePath) {
if (nodePath.isEmpty()) {
return this.agent;
}
return null;
}
}