link start!
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.file.FilePath
|
||||
* javax.baja.naming.UnresolvedException
|
||||
* javax.baja.spy.BSpy
|
||||
* javax.baja.spy.BSpySpace
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.LexiconText
|
||||
*/
|
||||
package com.tridium.fox.sys.spy;
|
||||
|
||||
import com.tridium.fox.sys.BFoxSession;
|
||||
import com.tridium.fox.sys.BIFoxProxySpace;
|
||||
import com.tridium.fox.sys.spy.BSpyChannel;
|
||||
import javax.baja.file.FilePath;
|
||||
import javax.baja.naming.UnresolvedException;
|
||||
import javax.baja.spy.BSpy;
|
||||
import javax.baja.spy.BSpySpace;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.LexiconText;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFoxSpySpace
|
||||
extends BSpySpace
|
||||
implements BIFoxProxySpace {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$fox$sys$spy$BFoxSpySpace;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void init(BFoxSession bFoxSession) {
|
||||
}
|
||||
|
||||
public void cleanup(BFoxSession bFoxSession) {
|
||||
}
|
||||
|
||||
public BSpy resolveSpy(FilePath filePath) {
|
||||
try {
|
||||
return this.channel().get(filePath);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
throw new UnresolvedException(filePath.toString(), (Throwable)exception);
|
||||
}
|
||||
}
|
||||
|
||||
public BFoxSession getFoxSession() {
|
||||
return (BFoxSession)this.getNavParent();
|
||||
}
|
||||
|
||||
public BSpyChannel channel() {
|
||||
return (BSpyChannel)this.getFoxSession().getConnection().getChannels().get("spy");
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BFoxSpySpace() {
|
||||
super("spy", LexiconText.make((String)"fox", (String)"nav.spy"));
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$fox$sys$spy$BFoxSpySpace;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$fox$sys$spy$BFoxSpySpace = BFoxSpySpace.class("[Lcom.tridium.fox.sys.spy.BFoxSpySpace;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.file.FilePath
|
||||
* javax.baja.security.PermissionException
|
||||
* javax.baja.spy.BSpy
|
||||
* javax.baja.spy.BSpySpace
|
||||
* javax.baja.spy.Spy
|
||||
* javax.baja.spy.SpyWriter
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.fox.sys.spy;
|
||||
|
||||
import com.tridium.fox.session.FoxRequest;
|
||||
import com.tridium.fox.session.FoxResponse;
|
||||
import com.tridium.fox.session.InvalidCommandException;
|
||||
import com.tridium.fox.sys.BFoxChannel;
|
||||
import com.tridium.fox.sys.spy.FoxSpy;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import javax.baja.file.FilePath;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.spy.BSpy;
|
||||
import javax.baja.spy.BSpySpace;
|
||||
import javax.baja.spy.Spy;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BSpyChannel
|
||||
extends BFoxChannel {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$fox$sys$spy$BSpyChannel;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public FoxResponse process(FoxRequest foxRequest) throws Exception {
|
||||
String string = foxRequest.command;
|
||||
if (string == "get") {
|
||||
return this.get(foxRequest);
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
public BSpy get(FilePath filePath) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("get");
|
||||
foxRequest.add("path", filePath.getBody());
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("c:get \"" + filePath.getBody() + '\"');
|
||||
}
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
String string = foxResponse.getString("title");
|
||||
byte[] byArray = foxResponse.getBlob("content");
|
||||
return BSpy.make((FilePath)filePath, (Spy)new FoxSpy(string, new String(byArray)));
|
||||
}
|
||||
|
||||
public FoxResponse get(FoxRequest foxRequest) throws Exception {
|
||||
BSpy bSpy;
|
||||
FilePath filePath = new FilePath(foxRequest.getString("path"));
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("s:get \"" + filePath.getBody() + '\"');
|
||||
}
|
||||
if (!this.getPermissionsFor(bSpy = BSpySpace.INSTANCE.resolveSpy(filePath)).hasOperatorRead()) {
|
||||
throw new PermissionException();
|
||||
}
|
||||
Spy spy = bSpy.get();
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
SpyWriter spyWriter = new SpyWriter((OutputStream)byteArrayOutputStream, filePath, this.getSessionContext());
|
||||
spy.write(spyWriter);
|
||||
spyWriter.flush();
|
||||
byte[] byArray = byteArrayOutputStream.toByteArray();
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
foxResponse.add("title", spy.getTitle());
|
||||
foxResponse.add("content", byArray);
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BSpyChannel() {
|
||||
super("spy");
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$fox$sys$spy$BSpyChannel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$fox$sys$spy$BSpyChannel = BSpyChannel.class("[Lcom.tridium.fox.sys.spy.BSpyChannel;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.spy.Spy
|
||||
* javax.baja.spy.SpyDir
|
||||
* javax.baja.spy.SpyWriter
|
||||
* javax.baja.sys.BObject
|
||||
*/
|
||||
package com.tridium.fox.sys.spy;
|
||||
|
||||
import com.tridium.fox.session.Fox;
|
||||
import com.tridium.fox.session.FoxConnection;
|
||||
import com.tridium.fox.session.FoxSession;
|
||||
import com.tridium.fox.sys.Acceptor;
|
||||
import com.tridium.fox.sys.BFoxClientConnection;
|
||||
import com.tridium.fox.sys.spy.FoxLog;
|
||||
import com.tridium.fox.sys.spy.FoxSessionSpy;
|
||||
import javax.baja.spy.Spy;
|
||||
import javax.baja.spy.SpyDir;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.BObject;
|
||||
|
||||
public class FoxIndexSpy
|
||||
extends SpyDir {
|
||||
public Spy find(String string) {
|
||||
if (string.equals("log")) {
|
||||
return new FoxLog.Index();
|
||||
}
|
||||
int n = Integer.parseInt(string.substring("session-".length()));
|
||||
FoxSession foxSession = Fox.getSession(n);
|
||||
return new FoxSessionSpy(foxSession);
|
||||
}
|
||||
|
||||
public void write(SpyWriter spyWriter) {
|
||||
FoxSession[] foxSessionArray = Fox.getSessions();
|
||||
spyWriter.startProps();
|
||||
spyWriter.trTitle((Object)"Fox", 2);
|
||||
spyWriter.prop((Object)"requestTimeout", Fox.requestTimeout);
|
||||
spyWriter.prop((Object)"keepAliveInterval", Fox.keepAliveInterval);
|
||||
spyWriter.prop((Object)"soTimeout", Fox.soTimeout);
|
||||
spyWriter.prop((Object)"tcpNoDelay", Fox.tcpNoDelay);
|
||||
spyWriter.prop((Object)"failsafeTimeouts", Fox.failsafeTimeouts);
|
||||
spyWriter.prop((Object)"foxDeadlocks", Fox.deadlocks);
|
||||
spyWriter.prop((Object)"maxServerSessions", Fox.maxServerSessions);
|
||||
spyWriter.prop((Object)"maxQueueSize", Fox.maxQueueSize);
|
||||
spyWriter.prop((Object)"circuitChunkSize", Fox.circuitChunkSize);
|
||||
spyWriter.prop((Object)"circuitMaxReceiveBuffer", Fox.circuitMaxReceiveBuffer);
|
||||
spyWriter.prop((Object)"hostName", (Object)Fox.hostName);
|
||||
spyWriter.prop((Object)"hostAddress", (Object)Fox.hostAddress);
|
||||
spyWriter.prop((Object)"app", (Object)(Fox.appName + ' ' + Fox.appVersion));
|
||||
spyWriter.prop((Object)"vm", (Object)(Fox.vmName + ' ' + Fox.vmVersion));
|
||||
spyWriter.prop((Object)"os", (Object)(Fox.osName + ' ' + Fox.osVersion));
|
||||
spyWriter.prop((Object)"exceptionTranslator", (Object)Fox.exceptionTranslator.getClass().getName());
|
||||
spyWriter.prop((Object)"engageLinger", (Object)("" + BFoxClientConnection.engageLinger));
|
||||
spyWriter.prop((Object)"license.tunneling.fox", Acceptor.foxTunnelingLicensed());
|
||||
spyWriter.trTitle((Object)"Fox Log", 2);
|
||||
spyWriter.prop((Object)"<a href='log'>Fox Log Index</a>", (Object)("size=" + FoxLog.size));
|
||||
spyWriter.trTitle((Object)"Client Sessions", 2);
|
||||
int n = 0;
|
||||
while (n < foxSessionArray.length) {
|
||||
if (!foxSessionArray[n].isServer()) {
|
||||
this.prop(spyWriter, foxSessionArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
spyWriter.trTitle((Object)("Server Sessions [cached count=" + Fox.getServerSessionCount() + ']'), 2);
|
||||
n = 0;
|
||||
while (n < foxSessionArray.length) {
|
||||
if (foxSessionArray[n].isServer()) {
|
||||
this.prop(spyWriter, foxSessionArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
spyWriter.trTitle((Object)"Fox Thread Pool Worker", 2);
|
||||
spyWriter.endProps();
|
||||
BFoxClientConnection.spyThreadPoolWorker(spyWriter);
|
||||
}
|
||||
|
||||
private final void prop(SpyWriter spyWriter, FoxSession foxSession) {
|
||||
Object object;
|
||||
String string = "session-" + foxSession.getId();
|
||||
FoxConnection foxConnection = foxSession.conn();
|
||||
int n = -1;
|
||||
if (foxConnection instanceof BObject && (object = ((BObject)foxConnection).fw(803, null, null, null, null)) instanceof Integer) {
|
||||
n = (Integer)object;
|
||||
}
|
||||
object = n != -1 ? string + "-fw" : string;
|
||||
spyWriter.prop((Object)("<a href='" + spyWriter.href(string) + "'>" + (String)object + "</a>"), (Object)foxSession);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,618 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.util.ThrowableUtil
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.nre.util.IntHashMap
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.spy.Spy
|
||||
* javax.baja.spy.SpyDir
|
||||
* javax.baja.spy.SpyWriter
|
||||
* javax.baja.sys.BRelTime
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Sys
|
||||
*/
|
||||
package com.tridium.fox.sys.spy;
|
||||
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import com.tridium.fox.session.Fox;
|
||||
import com.tridium.fox.session.FoxSession;
|
||||
import com.tridium.util.ThrowableUtil;
|
||||
import java.io.Writer;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.nre.util.IntHashMap;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.spy.Spy;
|
||||
import javax.baja.spy.SpyDir;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.BRelTime;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Sys;
|
||||
|
||||
public class FoxLog {
|
||||
static int nextWhoId = 0;
|
||||
static final int SERVER = 1;
|
||||
static final int ERROR = 3;
|
||||
static final int WARNING = 2;
|
||||
static final int MESSAGE = 1;
|
||||
static final int TRACE = 0;
|
||||
static final int OPENED = 10;
|
||||
static final int CLOSED = 11;
|
||||
static final int REJECTED = 12;
|
||||
static DateFormat format = new SimpleDateFormat("HH:mm:ss dd-MMM-yy z");
|
||||
static Object lock = new Object();
|
||||
static final int max;
|
||||
static int size;
|
||||
static Rec head;
|
||||
static Rec tail;
|
||||
static HashMap whoHistory;
|
||||
Log log;
|
||||
String logName;
|
||||
FoxSession session;
|
||||
|
||||
public static FoxLog make(String string) {
|
||||
return new FoxLog(Log.getLog((String)string));
|
||||
}
|
||||
|
||||
public Log log() {
|
||||
return this.log;
|
||||
}
|
||||
|
||||
public String getLogName() {
|
||||
return this.logName;
|
||||
}
|
||||
|
||||
public boolean isTraceOn() {
|
||||
return this.log.isTraceOn();
|
||||
}
|
||||
|
||||
public void error(String string) {
|
||||
this.log(3, string, null);
|
||||
}
|
||||
|
||||
public void error(String string, Throwable throwable) {
|
||||
this.log(3, string, throwable);
|
||||
}
|
||||
|
||||
public void warning(String string) {
|
||||
this.log(2, string, null);
|
||||
}
|
||||
|
||||
public void warning(String string, Throwable throwable) {
|
||||
this.log(2, string, throwable);
|
||||
}
|
||||
|
||||
public void message(String string) {
|
||||
this.log(1, string, null);
|
||||
}
|
||||
|
||||
public void message(String string, Throwable throwable) {
|
||||
this.log(1, string, throwable);
|
||||
}
|
||||
|
||||
public void trace(String string) {
|
||||
this.log(0, string, null);
|
||||
}
|
||||
|
||||
public void trace(String string, Throwable throwable) {
|
||||
this.log(0, string, throwable);
|
||||
}
|
||||
|
||||
public void log(int n, String string, Throwable throwable) {
|
||||
if (this.log.isLoggable(n)) {
|
||||
this.log.log(n, string, throwable);
|
||||
FoxLog.add(new Rec(n, this.session, this.logName, string, throwable));
|
||||
}
|
||||
}
|
||||
|
||||
public void logRecOnly(int n, String string) {
|
||||
if (this.log.isLoggable(n)) {
|
||||
FoxLog.add(new Rec(n, this.session, this.logName, string, null));
|
||||
}
|
||||
}
|
||||
|
||||
public FoxSession session() {
|
||||
return this.session;
|
||||
}
|
||||
|
||||
public void setSession(FoxSession foxSession) {
|
||||
this.session = foxSession;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void opened(FoxSession foxSession) {
|
||||
this.session = foxSession;
|
||||
String string = "Opened: " + FoxLog.toString(foxSession);
|
||||
if (!FoxLog.stationToStationConnection(foxSession)) {
|
||||
this.log.message(string);
|
||||
} else if (this.log.isTraceOn()) {
|
||||
this.log.trace(string);
|
||||
}
|
||||
FoxLog.add(new Rec(10, foxSession, this.logName, string, null));
|
||||
String string2 = FoxLog.toWho(foxSession);
|
||||
Object object = lock;
|
||||
synchronized (object) {
|
||||
Who who = (Who)whoHistory.get(string2);
|
||||
if (who == null) {
|
||||
who = new Who(string2);
|
||||
whoHistory.put(string2, who);
|
||||
}
|
||||
who.opened(foxSession);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void closed(FoxSession foxSession, Throwable throwable) {
|
||||
block10: {
|
||||
String string;
|
||||
int n;
|
||||
if (this.session == foxSession) {
|
||||
n = 11;
|
||||
string = "Closed: " + FoxLog.toString(foxSession);
|
||||
} else {
|
||||
n = 12;
|
||||
string = "Rejected: " + FoxLog.toString(foxSession);
|
||||
}
|
||||
if (!FoxLog.stationToStationConnection(foxSession)) {
|
||||
this.log.message(string);
|
||||
} else if (this.log.isTraceOn()) {
|
||||
this.log.trace(string);
|
||||
}
|
||||
FoxLog.add(new Rec(n, foxSession, this.logName, string, throwable));
|
||||
String string2 = FoxLog.toWho(foxSession);
|
||||
Object object = lock;
|
||||
synchronized (object) {
|
||||
Who who;
|
||||
block9: {
|
||||
who = (Who)whoHistory.get(string2);
|
||||
if (who == null) {
|
||||
who = new Who(string2);
|
||||
whoHistory.put(string2, who);
|
||||
}
|
||||
if (n != 11) break block9;
|
||||
who.closed(foxSession);
|
||||
break block10;
|
||||
}
|
||||
who.rejected(foxSession);
|
||||
}
|
||||
}
|
||||
this.session = null;
|
||||
}
|
||||
|
||||
public static String toWho(FoxSession foxSession) {
|
||||
if (foxSession == null) {
|
||||
return "null";
|
||||
}
|
||||
try {
|
||||
String string;
|
||||
FoxMessage foxMessage = foxSession.getRemoteHello();
|
||||
if (foxMessage == null) {
|
||||
foxMessage = new FoxMessage();
|
||||
try {
|
||||
string = foxSession.getSocket().getInetAddress().toString();
|
||||
}
|
||||
catch (NullPointerException nullPointerException) {
|
||||
string = "unknown";
|
||||
}
|
||||
} else {
|
||||
string = foxMessage.getString("hostName", "unknown");
|
||||
}
|
||||
String string2 = foxMessage.getString("app.name", "unknown");
|
||||
String string3 = foxMessage.getString("station.name", null);
|
||||
String string4 = foxMessage.getString("user", null);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(string2);
|
||||
if (string3 != null) {
|
||||
stringBuffer.append(" [").append(string3).append("]");
|
||||
} else if (string4 != null) {
|
||||
stringBuffer.append(" [").append(string4).append("]");
|
||||
}
|
||||
stringBuffer.append(" @ ").append(string);
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return "err";
|
||||
}
|
||||
}
|
||||
|
||||
public static String toString(FoxSession foxSession) {
|
||||
if (foxSession == null) {
|
||||
return "null";
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(foxSession.getId());
|
||||
stringBuffer.append(foxSession.isServer() ? " <- " : " -> ");
|
||||
stringBuffer.append(foxSession.getRemoteId());
|
||||
stringBuffer.append(" :: ");
|
||||
stringBuffer.append(FoxLog.toWho(foxSession));
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
static String toTime(long l) {
|
||||
if (l <= 0L) {
|
||||
return "null";
|
||||
}
|
||||
return format.format(new Date(Clock.millis() - Clock.ticks() + l));
|
||||
}
|
||||
|
||||
static String toAge(long l) {
|
||||
return BRelTime.toString((long)(Clock.ticks() - l));
|
||||
}
|
||||
|
||||
static String toDuration(long l) {
|
||||
return BRelTime.toString((long)l);
|
||||
}
|
||||
|
||||
static boolean stationToStationConnection(FoxSession foxSession) {
|
||||
try {
|
||||
String string = foxSession.getRemoteHello().getString("app.name", "");
|
||||
boolean bl = false;
|
||||
if (string.equals("Station") && string.equals(Fox.appName)) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void header(SpyWriter spyWriter) {
|
||||
spyWriter.w((Object)"\n");
|
||||
spyWriter.w((Object)Fox.appName).w((Object)" ").w((Object)Fox.appVersion);
|
||||
if (Sys.getStation() != null) {
|
||||
spyWriter.w((Object)(" [" + Sys.getStation().getStationName() + ']'));
|
||||
}
|
||||
spyWriter.w((Object)(" | " + FoxLog.toTime(Clock.ticks())));
|
||||
spyWriter.w((Object)" | <a href='/fox/log'>Log Index</a>");
|
||||
spyWriter.w((Object)(" | <a href='/fox/log/all'>All Records [" + size + "]</a>"));
|
||||
spyWriter.w((Object)"<hr>\n");
|
||||
}
|
||||
|
||||
static Who findWho(int n) {
|
||||
Iterator iterator = whoHistory.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Who who = (Who)iterator.next();
|
||||
if (who.id != n) continue;
|
||||
return who;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Rec findRec(int n) {
|
||||
Rec rec = head;
|
||||
while (rec != null) {
|
||||
if (rec.id == n) {
|
||||
return rec;
|
||||
}
|
||||
rec = rec.next;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
static void add(Rec rec) {
|
||||
Object object = lock;
|
||||
synchronized (object) {
|
||||
block5: {
|
||||
while (true) {
|
||||
if (size < max) {
|
||||
if (head != null) break;
|
||||
head = tail = rec;
|
||||
break block5;
|
||||
}
|
||||
head = FoxLog.head.next;
|
||||
--size;
|
||||
}
|
||||
rec.id = FoxLog.tail.id + 1;
|
||||
FoxLog.tail.next = rec;
|
||||
tail = rec;
|
||||
}
|
||||
++size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static String typeToString(int n) {
|
||||
switch (n) {
|
||||
case 3: {
|
||||
return "Error";
|
||||
}
|
||||
case 2: {
|
||||
return "Warning";
|
||||
}
|
||||
case 1: {
|
||||
return "Message";
|
||||
}
|
||||
case 0: {
|
||||
return "Trace";
|
||||
}
|
||||
case 10: {
|
||||
return "Opened";
|
||||
}
|
||||
case 11: {
|
||||
return "Closed";
|
||||
}
|
||||
case 12: {
|
||||
return "Rejected";
|
||||
}
|
||||
}
|
||||
return "?" + n + '?';
|
||||
}
|
||||
|
||||
private FoxLog(Log log) {
|
||||
this.log = log;
|
||||
this.logName = log.getLogName();
|
||||
}
|
||||
|
||||
static {
|
||||
int n = 1000;
|
||||
try {
|
||||
n = Integer.parseInt(System.getProperty("niagara.fox.logMax", "" + n));
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
max = n;
|
||||
whoHistory = new HashMap();
|
||||
FoxLog.add(new Rec(1, null, "fox", "Booted", null));
|
||||
}
|
||||
|
||||
static class Rec
|
||||
extends Spy {
|
||||
Rec next;
|
||||
int id;
|
||||
long ticks = Clock.ticks();
|
||||
int sessionId;
|
||||
int type;
|
||||
String logName;
|
||||
String msg;
|
||||
Throwable ex;
|
||||
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
FoxLog.header(spyWriter);
|
||||
spyWriter.startProps("Fox Log Record");
|
||||
spyWriter.prop((Object)"Id", (Object)("" + this.id));
|
||||
spyWriter.prop((Object)"Time", (Object)FoxLog.toTime(this.ticks));
|
||||
spyWriter.prop((Object)"Age", (Object)FoxLog.toAge(this.ticks));
|
||||
spyWriter.prop((Object)"Session", this.sessionId);
|
||||
spyWriter.prop((Object)"Type", (Object)FoxLog.typeToString(this.type));
|
||||
spyWriter.prop((Object)"LogName", (Object)this.logName);
|
||||
spyWriter.prop((Object)"Message", (Object)this.msg);
|
||||
spyWriter.endProps();
|
||||
if (this.ex != null) {
|
||||
spyWriter.w((Object)"<pre>");
|
||||
ThrowableUtil.dump((Writer)spyWriter, (Throwable)this.ex);
|
||||
spyWriter.w((Object)"</pre>");
|
||||
}
|
||||
}
|
||||
|
||||
Rec(int n, FoxSession foxSession, String string, String string2, Throwable throwable) {
|
||||
this.type = n;
|
||||
this.sessionId = foxSession == null ? -1 : foxSession.getId();
|
||||
this.logName = string;
|
||||
this.msg = string2;
|
||||
this.ex = throwable;
|
||||
}
|
||||
}
|
||||
|
||||
static class Who {
|
||||
int id = nextWhoId++;
|
||||
String key;
|
||||
int[] sessionIds;
|
||||
int[] remoteIds;
|
||||
long[] openTicks;
|
||||
long[] closeTicks;
|
||||
byte[] flags;
|
||||
|
||||
void opened(FoxSession foxSession) {
|
||||
System.arraycopy(this.sessionIds, 0, this.sessionIds, 1, this.sessionIds.length - 1);
|
||||
System.arraycopy(this.remoteIds, 0, this.remoteIds, 1, this.remoteIds.length - 1);
|
||||
System.arraycopy(this.openTicks, 0, this.openTicks, 1, this.openTicks.length - 1);
|
||||
System.arraycopy(this.closeTicks, 0, this.closeTicks, 1, this.closeTicks.length - 1);
|
||||
System.arraycopy(this.flags, 0, this.flags, 1, this.flags.length - 1);
|
||||
this.sessionIds[0] = foxSession.getId();
|
||||
this.remoteIds[0] = foxSession.getRemoteId();
|
||||
this.openTicks[0] = Clock.ticks();
|
||||
this.closeTicks[0] = -1;
|
||||
this.flags[0] = (byte)(foxSession.isServer() ? 1 : 0);
|
||||
}
|
||||
|
||||
void closed(FoxSession foxSession) {
|
||||
int n = foxSession.getId();
|
||||
int n2 = 0;
|
||||
while (n2 < this.sessionIds.length) {
|
||||
if (this.sessionIds[n2] == n) {
|
||||
this.closeTicks[n2] = Clock.ticks();
|
||||
break;
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
|
||||
void rejected(FoxSession foxSession) {
|
||||
this.opened(foxSession);
|
||||
this.closeTicks[0] = Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
IntHashMap sessionsToIntHashMap() {
|
||||
IntHashMap intHashMap = new IntHashMap();
|
||||
int n = 0;
|
||||
while (n < this.sessionIds.length) {
|
||||
int n2 = this.sessionIds[n];
|
||||
if (n2 >= 0) {
|
||||
intHashMap.put(n2, (Object)this);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
return intHashMap;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
Who(String string) {
|
||||
this.key = string;
|
||||
this.sessionIds = new int[20];
|
||||
this.remoteIds = new int[20];
|
||||
this.openTicks = new long[20];
|
||||
this.closeTicks = new long[20];
|
||||
this.flags = new byte[20];
|
||||
int n = 0;
|
||||
while (n < 20) {
|
||||
this.sessionIds[n] = -1;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class SpyRecs
|
||||
extends SpyDir {
|
||||
String title;
|
||||
IntHashMap sessions;
|
||||
|
||||
public Spy find(String string) {
|
||||
return FoxLog.findRec(Integer.parseInt(string));
|
||||
}
|
||||
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
FoxLog.header(spyWriter);
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle((Object)this.title, 6);
|
||||
spyWriter.w((Object)"<tr><th>Time</th><th>Age</th><th>Sid</th><th>Log</th><th>Message</th><th>Exception</th></tr>\n");
|
||||
Rec rec = head;
|
||||
while (rec != null) {
|
||||
if (this.include(rec)) {
|
||||
spyWriter.w((Object)"<tr");
|
||||
switch (rec.type) {
|
||||
case 3: {
|
||||
spyWriter.w((Object)" bgcolor='#FFAA26'");
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
spyWriter.w((Object)" bgcolor='#FFFF00'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
spyWriter.w((Object)">").td((Object)("<a href='" + rec.id + "'>" + FoxLog.toTime(rec.ticks) + "</a>")).td((Object)FoxLog.toAge(rec.ticks)).td((Object)("" + rec.sessionId)).td((Object)rec.logName).w((Object)"<td align='left' nowrap='true'>").safe(rec.msg).w((Object)"</td>").td((Object)(rec.ex == null ? "" : rec.ex.toString()));
|
||||
spyWriter.w((Object)"</tr>\n");
|
||||
}
|
||||
rec = rec.next;
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
|
||||
boolean include(Rec rec) {
|
||||
if (this.sessions == null) {
|
||||
return true;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.sessions.get(rec.sessionId) != null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
SpyRecs(String string, IntHashMap intHashMap) {
|
||||
this.title = string;
|
||||
this.sessions = intHashMap;
|
||||
}
|
||||
}
|
||||
|
||||
static class Index
|
||||
extends SpyDir {
|
||||
public Spy find(String string) {
|
||||
IntHashMap intHashMap;
|
||||
String string2;
|
||||
if (string.equals("all")) {
|
||||
string2 = "All Records";
|
||||
intHashMap = null;
|
||||
} else if (string.startsWith("byWho-")) {
|
||||
Who who = FoxLog.findWho(Integer.parseInt(string.substring(6)));
|
||||
string2 = "Records for " + who.key;
|
||||
intHashMap = who.sessionsToIntHashMap();
|
||||
} else if (string.startsWith("bySession-")) {
|
||||
int n = Integer.parseInt(string.substring(10));
|
||||
string2 = "Records for FoxSession " + n;
|
||||
intHashMap = new IntHashMap();
|
||||
intHashMap.put(n, (Object)this);
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return new SpyRecs(string2, intHashMap);
|
||||
}
|
||||
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
FoxLog.header(spyWriter);
|
||||
Object[] objectArray = whoHistory.values().toArray(new Who[whoHistory.size()]);
|
||||
SortUtil.sort((Object[])objectArray);
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle((Object)("Log of who has made fox connections [" + objectArray.length + ']'), 4);
|
||||
spyWriter.w((Object)"<tr><th>Session</th><th>Opened</th><th>Closed</th><th>Duration</th></tr>\n");
|
||||
int n = 0;
|
||||
while (n < objectArray.length) {
|
||||
Object object = objectArray[n];
|
||||
spyWriter.trTitle((Object)("<a href='byWho-" + ((Who)object).id + "'>" + object), 4);
|
||||
int n2 = ((Who)object).sessionIds.length - 1;
|
||||
while (n2 >= 0) {
|
||||
int n3 = ((Who)object).sessionIds[n2];
|
||||
if (n3 >= 0) {
|
||||
String string;
|
||||
String string2;
|
||||
int n4 = ((Who)object).remoteIds[n2];
|
||||
long l = ((Who)object).openTicks[n2];
|
||||
long l2 = ((Who)object).closeTicks[n2];
|
||||
boolean bl = false;
|
||||
if ((((Who)object).flags[n2] & 1) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
boolean bl2 = bl;
|
||||
String string3 = n3 + (bl2 ? " <- " : " -> ") + n4;
|
||||
boolean bl3 = false;
|
||||
if (l2 <= 0L) {
|
||||
string2 = "Open";
|
||||
string = FoxLog.toDuration(Clock.ticks() - l);
|
||||
bl3 = true;
|
||||
} else if (l2 == Long.MAX_VALUE) {
|
||||
string2 = "Rejected";
|
||||
string = "-";
|
||||
} else {
|
||||
string2 = FoxLog.toTime(l2);
|
||||
string = FoxLog.toDuration(l2 - l);
|
||||
}
|
||||
spyWriter.w((Object)"<tr").w((Object)(bl3 ? " bgcolor='#00ff00'" : "")).w((Object)">").td((Object)("<a href='bySession-" + n3 + "'>" + string3 + "</a>")).td((Object)FoxLog.toTime(l)).td((Object)string2).td((Object)string).w((Object)"</tr>\n");
|
||||
}
|
||||
--n2;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
|
||||
Index() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.spy.ObjectSpy
|
||||
* javax.baja.spy.Spy
|
||||
* javax.baja.spy.SpyDir
|
||||
* javax.baja.spy.SpyWriter
|
||||
* javax.baja.sys.BObject
|
||||
*/
|
||||
package com.tridium.fox.sys.spy;
|
||||
|
||||
import com.tridium.fox.session.FoxSession;
|
||||
import java.io.PrintWriter;
|
||||
import javax.baja.spy.ObjectSpy;
|
||||
import javax.baja.spy.Spy;
|
||||
import javax.baja.spy.SpyDir;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.BObject;
|
||||
|
||||
public class FoxSessionSpy
|
||||
extends SpyDir {
|
||||
private FoxSession session;
|
||||
|
||||
public void write(SpyWriter spyWriter) throws Exception {
|
||||
spyWriter.a("connection", "Session Connection Info");
|
||||
this.session.spy((PrintWriter)spyWriter);
|
||||
}
|
||||
|
||||
public Spy find(String string) {
|
||||
if (string.equals("connection") && this.session != null && this.session.conn() instanceof BObject) {
|
||||
return new ObjectSpy((BObject)this.session.conn());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public FoxSessionSpy(FoxSession foxSession) {
|
||||
this.session = foxSession;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.spy.Spy
|
||||
* javax.baja.spy.SpyWriter
|
||||
*/
|
||||
package com.tridium.fox.sys.spy;
|
||||
|
||||
import javax.baja.spy.Spy;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
|
||||
public class FoxSpy
|
||||
extends Spy {
|
||||
String title;
|
||||
String content;
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void write(SpyWriter spyWriter) {
|
||||
spyWriter.write(this.content);
|
||||
}
|
||||
|
||||
public FoxSpy(String string, String string2) {
|
||||
this.title = string;
|
||||
this.content = string2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user