link start!
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.OrdQuery
|
||||
* javax.baja.naming.OrdQueryList
|
||||
* javax.baja.naming.SyntaxException
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.baja.naming.OrdQuery;
|
||||
import javax.baja.naming.OrdQueryList;
|
||||
import javax.baja.naming.SyntaxException;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public class AlarmQuery
|
||||
implements OrdQuery {
|
||||
private String query;
|
||||
private HashMap paramMap;
|
||||
|
||||
public boolean isHost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSession() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void normalize(OrdQueryList ordQueryList, int n) {
|
||||
ordQueryList.shiftToSession(n);
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return "alarm";
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return this.query;
|
||||
}
|
||||
|
||||
public boolean isDbQuery() {
|
||||
this.parse();
|
||||
boolean bl = false;
|
||||
if (this.paramMap.size() == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public BUuid getUuid() {
|
||||
String string = (String)this.paramMap.get("uuid");
|
||||
if (string != null) {
|
||||
return BUuid.make((String)string);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getQueryParameter(String string, String string2) {
|
||||
this.parse();
|
||||
String string3 = (String)this.paramMap.get(string);
|
||||
if (string3 == null) {
|
||||
return string2;
|
||||
}
|
||||
return string3;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "alarm:" + this.query;
|
||||
}
|
||||
|
||||
public void parse() {
|
||||
if (this.paramMap != null) {
|
||||
return;
|
||||
}
|
||||
this.paramMap = new HashMap();
|
||||
if (this.query == null || this.query.length() == 0) {
|
||||
return;
|
||||
}
|
||||
int n = 0;
|
||||
int n2 = this.query.indexOf(61);
|
||||
while (n2 != -1) {
|
||||
String string = null;
|
||||
String string2 = null;
|
||||
int n3 = this.query.indexOf(59, n2);
|
||||
string = this.query.substring(n, n2);
|
||||
string2 = n3 == -1 ? this.query.substring(n2 + 1) : this.query.substring(n2 + 1, n3);
|
||||
this.paramMap.put(string, string2);
|
||||
if (n3 == -1) break;
|
||||
n = n3 + 1;
|
||||
n2 = this.query.indexOf(61, n);
|
||||
if (n2 != -1 || n == this.query.length()) continue;
|
||||
throw new SyntaxException("Expecting =");
|
||||
}
|
||||
}
|
||||
|
||||
public AlarmQuery(String string) {
|
||||
this.query = string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.BSelect
|
||||
* com.tridium.bql.SelectQuery
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.query.BExpression
|
||||
* javax.baja.query.util.Exprs
|
||||
* javax.baja.query.util.Predicates
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSimple
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.bql.BSelect;
|
||||
import com.tridium.bql.SelectQuery;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.query.BExpression;
|
||||
import javax.baja.query.util.Exprs;
|
||||
import javax.baja.query.util.Predicates;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAckPendingAlarmTable
|
||||
extends BAlarmTable
|
||||
implements Queryable {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAckPendingAlarmTable;
|
||||
|
||||
public Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().getAckPendingAlarms();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BAckPendingAlarmTable(this.getAlarmDb(), iFilter);
|
||||
}
|
||||
|
||||
public BObject bqlQuery(OrdTarget ordTarget, BqlQuery bqlQuery) {
|
||||
BExpression bExpression = Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.ackPending);
|
||||
BSelect bSelect = ((SelectQuery)bqlQuery).getSelect();
|
||||
if (bSelect.hasPredicate()) {
|
||||
bSelect.where(Exprs.builder((BExpression)bSelect.getPredicate().getPredicateExpr()).and(bExpression).getExpression());
|
||||
} else {
|
||||
bSelect.where(bExpression);
|
||||
}
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), (BqlQuery)new SelectQuery(bSelect));
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
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 BAckPendingAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
super(bAlarmDatabase);
|
||||
}
|
||||
|
||||
public BAckPendingAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAckPendingAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAckPendingAlarmTable = BAckPendingAlarmTable.class("[Lcom.tridium.alarm.db.BAckPendingAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmDbQueryResult
|
||||
extends BAlarmTable {
|
||||
public static final Type TYPE;
|
||||
private BqlQuery query;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAlarmDbQueryResult;
|
||||
|
||||
protected Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().doBqlQuery(this.query);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), this.query, iFilter);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
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 BAlarmDbQueryResult(BAlarmDatabase bAlarmDatabase, BqlQuery bqlQuery) {
|
||||
super(bAlarmDatabase);
|
||||
this.query = bqlQuery;
|
||||
}
|
||||
|
||||
public BAlarmDbQueryResult(BAlarmDatabase bAlarmDatabase, BqlQuery bqlQuery, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
this.query = bqlQuery;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAlarmDbQueryResult;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAlarmDbQueryResult = BAlarmDbQueryResult.class("[Lcom.tridium.alarm.db.BAlarmDbQueryResult;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.collection.BqlColumn
|
||||
* com.tridium.bql.collection.BqlColumnList
|
||||
* com.tridium.bql.collection.PropertyColumn
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BIList
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.AlarmTableCursor;
|
||||
import com.tridium.bql.collection.BqlColumn;
|
||||
import com.tridium.bql.collection.BqlColumnList;
|
||||
import com.tridium.bql.collection.PropertyColumn;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BIList;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BAlarmTable
|
||||
extends BObject
|
||||
implements BITable {
|
||||
public static final Type TYPE;
|
||||
private BAlarmDatabase db;
|
||||
private IFilter filter;
|
||||
private Context context;
|
||||
private BqlColumnList columns;
|
||||
private ArrayList recs;
|
||||
private BFacets tableFacets;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAlarmTable;
|
||||
|
||||
public BAlarmDatabase getAlarmDb() {
|
||||
return this.db;
|
||||
}
|
||||
|
||||
public Cursor cursor() {
|
||||
return new AlarmTableCursor(this, this.inner(), (javax.baja.nre.util.IFilter)this.filter);
|
||||
}
|
||||
|
||||
protected abstract Cursor inner();
|
||||
|
||||
public BIList toList() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BITable toTable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract BICollection filter(IFilter var1);
|
||||
|
||||
public int size() {
|
||||
this.load();
|
||||
return this.recs.size();
|
||||
}
|
||||
|
||||
public BObject get(int n) {
|
||||
return (BObject)this.recs.get(n);
|
||||
}
|
||||
|
||||
public BObject[] list() {
|
||||
this.load();
|
||||
return this.recs.toArray(new BObject[this.recs.size()]);
|
||||
}
|
||||
|
||||
public BObject[] list(BObject[] bObjectArray) {
|
||||
this.load();
|
||||
return this.recs.toArray(bObjectArray);
|
||||
}
|
||||
|
||||
public ColumnList getColumns() {
|
||||
if (this.columns == null) {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
Property[] propertyArray = bAlarmRecord.getPropertiesArray();
|
||||
BqlColumn[] bqlColumnArray = new BqlColumn[propertyArray.length];
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
Property property = propertyArray[n];
|
||||
Object var6_6 = null;
|
||||
bqlColumnArray[n] = new PropertyColumn(propertyArray[n]);
|
||||
++n;
|
||||
}
|
||||
this.columns = new BqlColumnList((Column[])bqlColumnArray);
|
||||
}
|
||||
return this.columns;
|
||||
}
|
||||
|
||||
public BObject get(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).get((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public String getString(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getString((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public float getFloat(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFloat((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public double getDouble(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getDouble((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getInt(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getInt((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public long getLong(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getLong((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public boolean getBoolean(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getBoolean((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getFlags(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFlags((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getFacets(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFacets((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getTableFacets() {
|
||||
return this.tableFacets;
|
||||
}
|
||||
|
||||
private final void load() {
|
||||
if (this.recs != null) {
|
||||
return;
|
||||
}
|
||||
this.recs = new ArrayList(1000);
|
||||
Cursor cursor = this.cursor();
|
||||
while (cursor.next()) {
|
||||
this.recs.add((BAlarmRecord)((BAlarmRecord)cursor.get()).newCopy());
|
||||
}
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
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 BAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
this(bAlarmDatabase, null);
|
||||
}
|
||||
|
||||
public BAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
this.db = bAlarmDatabase;
|
||||
this.filter = iFilter;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAlarmTable = BAlarmTable.class("[Lcom.tridium.alarm.db.BAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.sys.BInterface
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.sys.BInterface;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIAlarmResolver
|
||||
extends BInterface {
|
||||
public static final Type TYPE;
|
||||
|
||||
public OrdTarget resolve(BISession var1, OrdTarget var2, AlarmQuery var3);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$com$tridium$alarm$db$BIAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$com$tridium$alarm$db$BIAlarmResolver = 1.class("[Lcom.tridium.alarm.db.BIAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.agent.BIAgent
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.naming.UnresolvedException
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSingleton
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import com.tridium.alarm.db.BIAlarmResolver;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.naming.UnresolvedException;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSingleton;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BLocalAlarmResolver
|
||||
extends BSingleton
|
||||
implements BIAlarmResolver,
|
||||
BIAgent {
|
||||
public static final BLocalAlarmResolver INSTANCE = new BLocalAlarmResolver();
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BLocalAlarmResolver;
|
||||
|
||||
public final OrdTarget resolve(BISession bISession, OrdTarget ordTarget, AlarmQuery alarmQuery) {
|
||||
BOrd bOrd = BOrd.make((String)"service:alarm:AlarmService");
|
||||
BAlarmService bAlarmService = (BAlarmService)bOrd.resolve(ordTarget.get()).get();
|
||||
try {
|
||||
if (alarmQuery.isDbQuery()) {
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmService.getAlarmDb());
|
||||
}
|
||||
String string = alarmQuery.getQueryParameter("uuid", null);
|
||||
if (string != null) {
|
||||
BAlarmRecord bAlarmRecord = bAlarmService.getAlarmDb().getRecord(BUuid.make((String)string));
|
||||
if (bAlarmRecord == null) {
|
||||
throw new UnresolvedException(string);
|
||||
}
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmRecord);
|
||||
}
|
||||
throw new UnresolvedException("Invalid alarm query: " + alarmQuery);
|
||||
}
|
||||
catch (UnresolvedException unresolvedException) {
|
||||
throw unresolvedException;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new UnresolvedException("Cannot access alarm database.", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
private BLocalAlarmResolver() {
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BLocalAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BLocalAlarmResolver = BLocalAlarmResolver.class("[Lcom.tridium.alarm.db.BLocalAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.BSelect
|
||||
* com.tridium.bql.SelectQuery
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.query.BExpression
|
||||
* javax.baja.query.util.Exprs
|
||||
* javax.baja.query.util.Predicates
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSimple
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.bql.BSelect;
|
||||
import com.tridium.bql.SelectQuery;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.query.BExpression;
|
||||
import javax.baja.query.util.Exprs;
|
||||
import javax.baja.query.util.Predicates;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BOpenAlarmTable
|
||||
extends BAlarmTable
|
||||
implements Queryable {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BOpenAlarmTable;
|
||||
|
||||
public Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().getOpenAlarms();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BOpenAlarmTable(this.getAlarmDb(), iFilter);
|
||||
}
|
||||
|
||||
public BObject bqlQuery(OrdTarget ordTarget, BqlQuery bqlQuery) {
|
||||
BExpression bExpression = Predicates.and((BExpression)Predicates.not((BExpression)Predicates.and((BExpression)Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.acked), (BExpression)Predicates.eq((String)BAlarmRecord.sourceState.getName(), (BSimple)BSourceState.normal))), (BExpression)Predicates.not((BExpression)Predicates.and((BExpression)Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.acked), (BExpression)Predicates.eq((String)BAlarmRecord.sourceState.getName(), (BSimple)BSourceState.normal))));
|
||||
BSelect bSelect = ((SelectQuery)bqlQuery).getSelect();
|
||||
if (bSelect.hasPredicate()) {
|
||||
bSelect.where(Exprs.builder((BExpression)bSelect.getPredicate().getPredicateExpr()).and(bExpression).getExpression());
|
||||
} else {
|
||||
bSelect.where(bExpression);
|
||||
}
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), (BqlQuery)new SelectQuery(bSelect));
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
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 BOpenAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
super(bAlarmDatabase);
|
||||
}
|
||||
|
||||
public BOpenAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BOpenAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BOpenAlarmTable = BOpenAlarmTable.class("[Lcom.tridium.alarm.db.BOpenAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class AckPendingIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private IndexEntry first = null;
|
||||
private IndexEntry last = null;
|
||||
private int size = 0;
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public void add(IndexEntry indexEntry) {
|
||||
if (indexEntry.isAckPending()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setAckPending(true);
|
||||
indexEntry.nextAckPending = null;
|
||||
indexEntry.prevAckPending = null;
|
||||
if (this.size == 0) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
IndexEntry indexEntry2 = indexEntry.prevTimestamp;
|
||||
while (indexEntry2 != null && !indexEntry2.isAckPending()) {
|
||||
indexEntry2 = indexEntry2.prevTimestamp;
|
||||
}
|
||||
if (indexEntry2 == null) {
|
||||
if (this.first == null) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
indexEntry.nextAckPending = this.first;
|
||||
this.first.prevAckPending = indexEntry;
|
||||
this.first = indexEntry;
|
||||
}
|
||||
} else {
|
||||
indexEntry.nextAckPending = indexEntry2.nextAckPending;
|
||||
indexEntry.prevAckPending = indexEntry2;
|
||||
if (indexEntry2.nextAckPending != null) {
|
||||
indexEntry2.nextAckPending.prevAckPending = indexEntry;
|
||||
}
|
||||
indexEntry2.nextAckPending = indexEntry;
|
||||
if (indexEntry.prevAckPending == this.last) {
|
||||
this.last = indexEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0 || indexEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (!indexEntry.isAckPending()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setAckPending(false);
|
||||
if (indexEntry.prevAckPending != null) {
|
||||
indexEntry.prevAckPending.nextAckPending = indexEntry.nextAckPending;
|
||||
}
|
||||
if (indexEntry.nextAckPending != null) {
|
||||
indexEntry.nextAckPending.prevAckPending = indexEntry.prevAckPending;
|
||||
}
|
||||
if (indexEntry == this.first) {
|
||||
this.first = indexEntry.nextAckPending;
|
||||
}
|
||||
if (indexEntry == this.last) {
|
||||
this.last = indexEntry.prevAckPending;
|
||||
}
|
||||
indexEntry.nextAckPending = null;
|
||||
indexEntry.prevAckPending = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
IndexEntry indexEntry = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ") " + indexEntry.timestamp.toString((Context)showSecs) + " ackPending=" + indexEntry.isAckPending());
|
||||
indexEntry = indexEntry.nextAckPending;
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isAfter(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is before " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isAckPending()) {
|
||||
throw new IllegalStateException("Cleared alarm in ackPending index, ascending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.nextAckPending;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry = null;
|
||||
indexEntry2 = this.last;
|
||||
n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isBefore(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is after " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isAckPending()) {
|
||||
throw new IllegalStateException("Cleared alarm in ackPending index, descending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.prevAckPending;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.SkipList;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmSourceIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private HashMap table;
|
||||
private double probability;
|
||||
private int maxSizePerSource;
|
||||
|
||||
public synchronized IndexEntry getListForSource(BOrdList bOrdList) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
return null;
|
||||
}
|
||||
return sourceList.getFirstEntry();
|
||||
}
|
||||
|
||||
public synchronized void add(BOrdList bOrdList, IndexEntry indexEntry) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
sourceList = new SourceList(this.probability, this.maxSizePerSource);
|
||||
this.table.put(bOrdList, sourceList);
|
||||
sourceList.add(indexEntry);
|
||||
} else {
|
||||
sourceList.add(indexEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(BOrdList bOrdList, IndexEntry indexEntry) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
return;
|
||||
}
|
||||
sourceList.remove(indexEntry);
|
||||
}
|
||||
|
||||
public IndexEntry getNext(IndexEntry indexEntry) {
|
||||
return indexEntry.nextSource[0];
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.table = new HashMap(1001);
|
||||
}
|
||||
|
||||
public AlarmSourceIndex(double d, int n) {
|
||||
this.this();
|
||||
this.probability = d;
|
||||
this.maxSizePerSource = n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class SourceList
|
||||
extends SkipList {
|
||||
public int compare(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
int n = indexEntry.timestamp.compareTo((Object)indexEntry2.timestamp);
|
||||
if (n == 0) {
|
||||
return indexEntry.pageIndex - indexEntry2.pageIndex;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public int compareToKey(IndexEntry indexEntry, Object object) {
|
||||
return indexEntry.timestamp.compareTo((Object)((BAbsTime)object));
|
||||
}
|
||||
|
||||
public int getLevel(IndexEntry indexEntry) {
|
||||
return indexEntry.nextSource.length;
|
||||
}
|
||||
|
||||
public void setLevel(IndexEntry indexEntry, int n) {
|
||||
indexEntry.nextSource = new IndexEntry[n];
|
||||
}
|
||||
|
||||
public IndexEntry getNext(IndexEntry indexEntry, int n) {
|
||||
return indexEntry.nextSource[n];
|
||||
}
|
||||
|
||||
public void setNext(IndexEntry indexEntry, int n, IndexEntry indexEntry2) {
|
||||
indexEntry.nextSource[n] = indexEntry2;
|
||||
}
|
||||
|
||||
public IndexEntry getPrev(IndexEntry indexEntry) {
|
||||
return indexEntry.prevSource;
|
||||
}
|
||||
|
||||
public void setPrev(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
indexEntry.prevSource = indexEntry2;
|
||||
}
|
||||
|
||||
public String entryToString(IndexEntry indexEntry) {
|
||||
return indexEntry.timestamp.toString((Context)BAlarmRecord.TIMESTAMP_FACETS) + " => " + indexEntry.pageIndex;
|
||||
}
|
||||
|
||||
public SourceList(double d, int n) {
|
||||
super(d, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,794 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.io.ByteBuffer
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AckPendingIndex;
|
||||
import com.tridium.alarm.db.file.AlarmSourceIndex;
|
||||
import com.tridium.alarm.db.file.AlarmStoreHeader;
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import com.tridium.alarm.db.file.BlockCache;
|
||||
import com.tridium.alarm.db.file.FreePageMap;
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.OpenIndex;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import com.tridium.alarm.db.file.PageReader;
|
||||
import com.tridium.alarm.db.file.TimestampIndex;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmStore {
|
||||
private static final int BLOCK_CACHE_SIZE = 10;
|
||||
private static final int MAX_SIZE = 250000;
|
||||
private static final int MAX_SIZE_PER_SOURCE = 10000;
|
||||
private File alarmFile;
|
||||
private RandomAccessFile io;
|
||||
private int capacity;
|
||||
private AlarmStoreHeader header;
|
||||
private FreePageMap freeMap;
|
||||
private BlockCache blockCache;
|
||||
private ByteBuffer writeBuf;
|
||||
private PageReader reader;
|
||||
private int[] recPages;
|
||||
private HashMap byUuid;
|
||||
private TimestampIndex timestampIndex;
|
||||
private AlarmSourceIndex sourceIndex;
|
||||
private OpenIndex openIndex;
|
||||
private AckPendingIndex ackPendingIndex;
|
||||
private BAlarmRecord trimRec;
|
||||
private BAlarmService alarmService;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClass;
|
||||
|
||||
public AlarmStoreHeader getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public void setCapacity(int n) {
|
||||
this.capacity = n;
|
||||
}
|
||||
|
||||
public synchronized void open() throws IOException {
|
||||
this.byUuid = new HashMap();
|
||||
this.timestampIndex = new TimestampIndex(0.5, 250000);
|
||||
this.sourceIndex = new AlarmSourceIndex(0.5, 10000);
|
||||
this.openIndex = new OpenIndex();
|
||||
this.ackPendingIndex = new AckPendingIndex();
|
||||
this.blockCache = new BlockCache(this, 10);
|
||||
this.io = new RandomAccessFile(this.alarmFile, "rw");
|
||||
try {
|
||||
if (this.io.length() == 0L) {
|
||||
this.create();
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
this.io.close();
|
||||
this.io = null;
|
||||
throw iOException;
|
||||
}
|
||||
catch (RuntimeException runtimeException) {
|
||||
this.io.close();
|
||||
this.io = null;
|
||||
throw runtimeException;
|
||||
}
|
||||
this.writeBuf = new ByteBuffer(this.header.getPageSize());
|
||||
}
|
||||
|
||||
private final void create() throws IOException {
|
||||
this.header = new AlarmStoreHeader(new BAlarmRecord().getSerialVersionId());
|
||||
this.io.seek(0L);
|
||||
this.header.write(this.io);
|
||||
this.freeMap = new FreePageMap();
|
||||
BAlarmDatabase.log.message("Created");
|
||||
}
|
||||
|
||||
private final void init() throws IOException {
|
||||
BAlarmDatabase.log.message("Loading...");
|
||||
this.header = new AlarmStoreHeader();
|
||||
this.io.seek(0L);
|
||||
this.header.read(this.io);
|
||||
int n = new BAlarmRecord().getSerialVersionId();
|
||||
if (this.header.getRecordVersion() != n) {
|
||||
throw new IOException("Incompatible record versions. (expected=" + n + ", actual=" + this.header.getRecordVersion() + ')');
|
||||
}
|
||||
this.freeMap = new FreePageMap();
|
||||
int n2 = (int)((this.io.length() - this.header.getDataOffset()) / (long)this.header.getPageSize());
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
BAlarmRecord bAlarmRecord2 = new BAlarmRecord();
|
||||
long l = Clock.ticks();
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < n2) {
|
||||
block11: {
|
||||
block13: {
|
||||
block12: {
|
||||
Page page = this.readPage(n4);
|
||||
if (page.getPageOfRecord() != 0) break block11;
|
||||
if ((bAlarmRecord = this.readRecord(n4, bAlarmRecord, this.freeMap)) != null) break block12;
|
||||
if (++n3 == 20) {
|
||||
throw new IOException("Alarm database is invalid. Too many invalid records read during init.");
|
||||
}
|
||||
break block11;
|
||||
}
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
if (indexEntry == null) break block13;
|
||||
if ((bAlarmRecord2 = this.readRecord(indexEntry.pageIndex, bAlarmRecord2, null)).getLastUpdate().isAfter(bAlarmRecord.getLastUpdate())) break block11;
|
||||
this.freePageRun(indexEntry.pageIndex);
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, n4);
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
long l2 = Clock.ticks();
|
||||
BAlarmDatabase.log.message("Loaded [" + (l2 - l) + "ms, " + this.getRecordCount() + " alarms, " + n2 + " pages]");
|
||||
}
|
||||
|
||||
public synchronized void close() {
|
||||
if (this.io != null) {
|
||||
try {
|
||||
this.io.close();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
this.io = null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
if (!this.byUuid.containsKey(bAlarmRecord.getUuid())) {
|
||||
this.append(bAlarmRecord, false);
|
||||
this.trimToCapacity();
|
||||
} else {
|
||||
this.update(bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void append(BAlarmRecord bAlarmRecord, boolean bl) throws IOException {
|
||||
Object object;
|
||||
this.writeBuf.reset();
|
||||
bAlarmRecord.write((DataOutput)this.writeBuf);
|
||||
bAlarmRecord.getUuid().encode((DataOutput)this.writeBuf);
|
||||
byte[] byArray = this.writeBuf.getBytes();
|
||||
int n = this.writeBuf.getLength();
|
||||
int n2 = 0;
|
||||
int n3 = this.header.getPageSize() - 12;
|
||||
int n4 = n / n3;
|
||||
if (n % n3 != 0) {
|
||||
++n4;
|
||||
}
|
||||
int[] nArray = this.takePages(n4);
|
||||
if (!bl) {
|
||||
object = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (object.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
object.setTotalAlarmCount(object.getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
object.setUnackedAlarmCount(object.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
object.setOpenAlarmCount(object.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
object.setInAlarmCount(object.getInAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, nArray[0]);
|
||||
} else {
|
||||
object = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
BAlarmRecord bAlarmRecord2 = this.readRecord(((IndexEntry)object).pageIndex, null);
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
if (!((IndexEntry)object).isAcked() && bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
} else if (((IndexEntry)object).isAcked() && !bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (!((IndexEntry)object).isOpen() && bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (((IndexEntry)object).isOpen() && !bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (((IndexEntry)object).isNormal() && !bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() + 1);
|
||||
}
|
||||
if (!((IndexEntry)object).isNormal() && bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
this.updateIndices(bAlarmRecord, bAlarmRecord2, nArray[0]);
|
||||
}
|
||||
int n5 = 0;
|
||||
while (n5 < n4) {
|
||||
int n6 = nArray[n5];
|
||||
int n7 = n5 == n4 - 1 ? -1 : nArray[n5 + 1];
|
||||
Page page = this.readPage(n6);
|
||||
int n8 = Math.min(n - n2, n3);
|
||||
page.write(n5, n4, n7, byArray, n2, n8);
|
||||
n2 += n8;
|
||||
++n5;
|
||||
}
|
||||
if (n2 != n) {
|
||||
throw new IOException("Write error: " + n2 + " of " + n + " bytes written.");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
int n = -1;
|
||||
if (indexEntry != null) {
|
||||
n = indexEntry.pageIndex;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (indexEntry != null) {
|
||||
bl = true;
|
||||
}
|
||||
this.append(bAlarmRecord, bl);
|
||||
if (n != -1) {
|
||||
this.freePageRun(n);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void remove(IndexEntry indexEntry, BAlarmRecord bAlarmRecord) throws IOException {
|
||||
if (indexEntry == null && bAlarmRecord == null) {
|
||||
return;
|
||||
}
|
||||
if (indexEntry == null && (indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid())) == null) {
|
||||
return;
|
||||
}
|
||||
bAlarmRecord = this.readRecord(indexEntry.pageIndex, bAlarmRecord, null);
|
||||
this.byUuid.remove(bAlarmRecord.getUuid());
|
||||
this.timestampIndex.remove(indexEntry);
|
||||
this.sourceIndex.remove(bAlarmRecord.getSource(), indexEntry);
|
||||
if (indexEntry.isOpen()) {
|
||||
this.openIndex.remove(indexEntry);
|
||||
}
|
||||
if (indexEntry.isAckPending()) {
|
||||
this.ackPendingIndex.remove(indexEntry);
|
||||
}
|
||||
this.freePageRun(indexEntry.pageIndex);
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
indexEntry.nextTimestamp = null;
|
||||
indexEntry.prevTimestamp = null;
|
||||
indexEntry.nextSource = null;
|
||||
indexEntry.prevSource = null;
|
||||
indexEntry = null;
|
||||
}
|
||||
|
||||
private final synchronized void addToIndices(BAlarmRecord bAlarmRecord, int n) {
|
||||
IndexEntry indexEntry = new IndexEntry(bAlarmRecord, n);
|
||||
this.byUuid.put(bAlarmRecord.getUuid(), indexEntry);
|
||||
this.timestampIndex.add(indexEntry);
|
||||
this.sourceIndex.add(bAlarmRecord.getSource(), indexEntry);
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
this.openIndex.add(indexEntry);
|
||||
}
|
||||
if (bAlarmRecord.isAckPending()) {
|
||||
this.ackPendingIndex.add(indexEntry);
|
||||
}
|
||||
indexEntry.setAcked(bAlarmRecord.isAcknowledged());
|
||||
indexEntry.setNormal(bAlarmRecord.isNormal());
|
||||
indexEntry.setAckPending(bAlarmRecord.isAckPending());
|
||||
}
|
||||
|
||||
private final synchronized void updateIndices(BAlarmRecord bAlarmRecord, BAlarmRecord bAlarmRecord2, int n) {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
if (indexEntry != null) {
|
||||
this.byUuid.remove(bAlarmRecord.getUuid());
|
||||
this.timestampIndex.remove(indexEntry);
|
||||
this.sourceIndex.remove(bAlarmRecord2.getSource(), indexEntry);
|
||||
if (indexEntry.isOpen()) {
|
||||
this.openIndex.remove(indexEntry);
|
||||
}
|
||||
if (indexEntry.isAckPending()) {
|
||||
this.ackPendingIndex.remove(indexEntry);
|
||||
}
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, n);
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
this.blockCache.flush();
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
return this.timestampIndex.getSize();
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord getRecord(BUuid bUuid) throws IOException {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bUuid);
|
||||
if (indexEntry != null) {
|
||||
return this.readRecord(indexEntry.pageIndex, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() {
|
||||
return new TimestampCursor(this, this.timestampIndex.getFirstEntry(), null);
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) {
|
||||
IndexEntry indexEntry = null;
|
||||
if (bAbsTime == null || bAbsTime.isNull()) {
|
||||
indexEntry = this.timestampIndex.getFirstEntry();
|
||||
} else {
|
||||
indexEntry = this.timestampIndex.find(bAbsTime);
|
||||
if (indexEntry != null) {
|
||||
indexEntry = indexEntry.nextTimestamp[0];
|
||||
}
|
||||
}
|
||||
return new TimestampCursor(this, indexEntry, bAbsTime2);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
IndexEntry indexEntry = this.sourceIndex.getListForSource(bOrdList);
|
||||
return new SourceCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor getOpenAlarms() throws IOException {
|
||||
IndexEntry indexEntry = this.openIndex.getFirstEntry();
|
||||
return new OpenCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAckPendingAlarms() throws IOException {
|
||||
IndexEntry indexEntry = this.ackPendingIndex.getFirstEntry();
|
||||
return new AckPendingCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
private final synchronized int[] takePages(int n) throws IOException {
|
||||
if (this.recPages == null || this.recPages.length < n) {
|
||||
this.recPages = new int[n];
|
||||
}
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
this.recPages[n2] = this.nextFreePage();
|
||||
this.freeMap.setFree(this.recPages[n2], false);
|
||||
++n2;
|
||||
}
|
||||
return this.recPages;
|
||||
}
|
||||
|
||||
private final synchronized void freePageRun(int n) throws IOException {
|
||||
int n2 = n;
|
||||
do {
|
||||
Page page;
|
||||
if ((page = this.readPage(n2)) == null) {
|
||||
return;
|
||||
}
|
||||
this.freeMap.setFree(n2, true);
|
||||
n2 = page.getNextPage();
|
||||
page.clear();
|
||||
} while (n2 != -1);
|
||||
}
|
||||
|
||||
private final synchronized int nextFreePage() throws IOException {
|
||||
int n = this.freeMap.getFreePage();
|
||||
if (n == -1) {
|
||||
this.grow();
|
||||
}
|
||||
if ((n = this.freeMap.getFreePage()) == -1) {
|
||||
throw new IOException("Cannot allocate a new page.");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public synchronized Page readPage(int n) throws IOException {
|
||||
int n2 = this.header.getPagesPerBlock();
|
||||
int n3 = n / n2;
|
||||
int n4 = n - n3 * n2;
|
||||
return this.getBlock(n3).getPage(n4);
|
||||
}
|
||||
|
||||
private final synchronized void grow() throws IOException {
|
||||
int n = this.header.getPageSize();
|
||||
int n2 = this.header.getPagesPerBlock();
|
||||
int n3 = n * n2;
|
||||
int n4 = (int)((this.io.length() - this.header.getDataOffset()) / (long)n3);
|
||||
Block block = new Block(this, n4);
|
||||
block.clear();
|
||||
this.io.seek(this.io.length());
|
||||
block.write(this.io);
|
||||
this.freeMap.addFreePages(this.header.getPagesPerBlock());
|
||||
}
|
||||
|
||||
synchronized Block getBlock(int n) throws IOException {
|
||||
Block block = this.blockCache.getBlock(n);
|
||||
if (block == null) {
|
||||
block = this.readBlock(n);
|
||||
this.blockCache.add(block);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
synchronized Block readBlock(int n) throws IOException {
|
||||
Block block = new Block(this, n);
|
||||
long l = this.header.getDataOffset() + (long)(n * block.getSize());
|
||||
this.io.seek(l);
|
||||
block.read(this.io);
|
||||
return block;
|
||||
}
|
||||
|
||||
synchronized void writeBlock(Block block) throws IOException {
|
||||
if (!block.isDirty()) {
|
||||
return;
|
||||
}
|
||||
int n = block.getIndex();
|
||||
long l = this.header.getDataOffset() + (long)(n * block.getSize());
|
||||
this.io.seek(l);
|
||||
block.write(this.io);
|
||||
}
|
||||
|
||||
public BAlarmRecord readRecord(int n, BAlarmRecord bAlarmRecord) throws IOException {
|
||||
return this.readRecord(n, bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord readRecord(int n, BAlarmRecord bAlarmRecord, FreePageMap freePageMap) throws IOException {
|
||||
if (bAlarmRecord == null) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
}
|
||||
if (this.reader == null) {
|
||||
this.reader = new PageReader(this, n);
|
||||
} else {
|
||||
this.reader.init(n);
|
||||
}
|
||||
try {
|
||||
bAlarmRecord.read(this.reader);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return null;
|
||||
}
|
||||
BUuid bUuid = (BUuid)BUuid.DEFAULT.decode((DataInput)this.reader);
|
||||
if (!bAlarmRecord.getUuid().equals((Object)bUuid)) {
|
||||
return null;
|
||||
}
|
||||
if (freePageMap != null) {
|
||||
int n2 = this.reader.getPageCount();
|
||||
int n3 = 0;
|
||||
while (n3 < n2) {
|
||||
freePageMap.setFree(this.reader.getPageIndex(n3), false);
|
||||
++n3;
|
||||
}
|
||||
}
|
||||
return bAlarmRecord;
|
||||
}
|
||||
|
||||
public synchronized void trimToCapacity() throws IOException {
|
||||
if (this.timestampIndex.getSize() > this.capacity) {
|
||||
if (this.trimRec == null) {
|
||||
this.trimRec = new BAlarmRecord();
|
||||
}
|
||||
while (this.timestampIndex.getSize() > this.capacity) {
|
||||
this.remove(this.timestampIndex.getFirstEntry(), this.trimRec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.close();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmClass;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmClass = AlarmStore.class("[Ljavax.baja.alarm.BAlarmClass;", false);
|
||||
}
|
||||
BAlarmClass[] bAlarmClassArray = (BAlarmClass[])this.alarmService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bAlarmClassArray.length) {
|
||||
bAlarmClassArray[n].setTotalAlarmCount(0);
|
||||
bAlarmClassArray[n].setUnackedAlarmCount(0);
|
||||
bAlarmClassArray[n].setOpenAlarmCount(0);
|
||||
bAlarmClassArray[n].setInAlarmCount(0);
|
||||
++n;
|
||||
}
|
||||
if (!this.alarmFile.delete()) {
|
||||
this.open();
|
||||
throw new IOException("Cannot delete alarm history file: " + this.alarmFile.getAbsolutePath());
|
||||
}
|
||||
this.open();
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
if (this.timestampIndex.getSize() == 0) {
|
||||
return;
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
while (this.timestampIndex.getSize() > 0) {
|
||||
IndexEntry indexEntry = this.timestampIndex.getFirstEntry();
|
||||
if (!indexEntry.timestamp.isBefore(bAbsTime)) break;
|
||||
this.remove(indexEntry, bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
if (this.byUuid.size() == 0) {
|
||||
return;
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bUuid);
|
||||
if (indexEntry != null) {
|
||||
this.remove(indexEntry, bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public void analyze(PrintStream printStream) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###,###,###,###");
|
||||
DecimalFormat decimalFormat2 = new DecimalFormat("###,###,###.##");
|
||||
DecimalFormat decimalFormat3 = new DecimalFormat("###,###,###");
|
||||
printStream.println("db file : " + this.alarmFile.getAbsolutePath());
|
||||
printStream.println("file size : " + decimalFormat.format(this.alarmFile.length()));
|
||||
printStream.println("capacity : " + this.capacity);
|
||||
printStream.println("record count: " + this.timestampIndex.getSize());
|
||||
printStream.println("free map : " + decimalFormat3.format(this.freeMap.getSizeInBytes()) + " bytes");
|
||||
this.timestampIndex.analyze("timestamp index", printStream);
|
||||
printStream.println();
|
||||
int n = this.timestampIndex.getSize() * 21;
|
||||
printStream.println("non-list entry ram: " + decimalFormat2.format((double)n / 1024.0 / 1024.0) + " MB");
|
||||
}
|
||||
|
||||
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 AlarmStore(File file, int n) {
|
||||
this.alarmFile = file;
|
||||
this.capacity = n;
|
||||
this.alarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
|
||||
private static class TimestampCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
if (indexEntry.nextTimestamp == null) {
|
||||
return null;
|
||||
}
|
||||
return indexEntry.nextTimestamp[0];
|
||||
}
|
||||
|
||||
public TimestampCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SourceCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
if (indexEntry.nextSource == null) {
|
||||
return null;
|
||||
}
|
||||
return indexEntry.nextSource[0];
|
||||
}
|
||||
|
||||
public SourceCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class OpenCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
return indexEntry.nextOpen;
|
||||
}
|
||||
|
||||
public OpenCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AckPendingCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
return indexEntry.nextAckPending;
|
||||
}
|
||||
|
||||
public AckPendingCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private static abstract class AlarmStoreCursor
|
||||
implements Cursor {
|
||||
boolean init = true;
|
||||
AlarmStore store;
|
||||
IndexEntry entry;
|
||||
BAlarmRecord rec;
|
||||
BAbsTime endTime;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Context getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.init) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
if (this.entry != null) {
|
||||
return this.rec;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
* Converted monitor instructions to comments
|
||||
* Lifted jumps to return sites
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.entry == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.init) {
|
||||
this.init = false;
|
||||
try {
|
||||
AlarmStore alarmStore = this.store;
|
||||
// MONITORENTER : alarmStore
|
||||
if (this.store.io == null) {
|
||||
throw new IllegalStateException("Alarm database is closed.");
|
||||
}
|
||||
if (-1 == this.store.readPage(this.entry.pageIndex).getPageOfRecord()) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
if (!this.store.readRecord(this.entry.pageIndex, this.rec).getTimestamp().equals((Object)this.entry.timestamp)) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
// MONITOREXIT : alarmStore
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return false;
|
||||
}
|
||||
if (this.endTime == null) return true;
|
||||
if (!this.rec.getTimestamp().isAfter(this.endTime)) return true;
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
this.entry = this.nextEntry(this.entry);
|
||||
if (this.entry == null) {
|
||||
this.rec = null;
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
AlarmStore alarmStore = this.store;
|
||||
// MONITORENTER : alarmStore
|
||||
if (this.store.io == null) {
|
||||
throw new IllegalStateException("Alarm database is closed.");
|
||||
}
|
||||
if (-1 == this.store.readPage(this.entry.pageIndex).getPageOfRecord()) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
if (!this.store.readRecord(this.entry.pageIndex, this.rec).getTimestamp().equals((Object)this.entry.timestamp)) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
// MONITOREXIT : alarmStore
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return false;
|
||||
}
|
||||
if (this.endTime == null) return true;
|
||||
if (!this.rec.getTimestamp().isAfter(this.endTime)) return true;
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = AlarmStoreCursor.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.equals(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract IndexEntry nextEntry(IndexEntry var1);
|
||||
|
||||
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 AlarmStoreCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
this.store = alarmStore;
|
||||
this.entry = indexEntry;
|
||||
this.rec = new BAlarmRecord();
|
||||
this.endTime = bAbsTime;
|
||||
if (this.endTime != null && this.endTime.isNull()) {
|
||||
this.endTime = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.io.ByteBuffer
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmStoreHeader {
|
||||
private static final int MAGIC = 1611526157;
|
||||
private static final int LATEST_VERSION = 1;
|
||||
private static final int DEFAULT_HEADER_SIZE = 1024;
|
||||
private static final int DEFAULT_PAGE_SIZE = 512;
|
||||
private static final int DEFAULT_PAGES_PER_BLOCK = 8;
|
||||
private long creationTime;
|
||||
private int version;
|
||||
private int recordVersion;
|
||||
private long dataOffset;
|
||||
private int pageSize;
|
||||
private int pagesPerBlock;
|
||||
private boolean newStore;
|
||||
private ByteBuffer writeBuffer;
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
if (this.writeBuffer == null) {
|
||||
this.writeBuffer = new ByteBuffer(1024);
|
||||
} else {
|
||||
this.writeBuffer.reset();
|
||||
}
|
||||
this.writeBuffer.writeInt(1611526157);
|
||||
this.writeBuffer.writeInt(this.version);
|
||||
this.writeBuffer.writeInt(this.recordVersion);
|
||||
this.writeBuffer.writeLong(this.creationTime);
|
||||
this.writeBuffer.writeInt(this.pageSize);
|
||||
this.writeBuffer.writeInt(this.pagesPerBlock);
|
||||
int n = this.writeBuffer.getLength();
|
||||
int n2 = n + 8;
|
||||
if (this.newStore) {
|
||||
this.writeBuffer.writeTo(dataOutput, 0, n);
|
||||
this.dataOffset = Math.max(n2, 1024);
|
||||
dataOutput.writeLong(this.dataOffset);
|
||||
int n3 = (int)this.dataOffset - n2;
|
||||
dataOutput.write(new byte[n3]);
|
||||
} else {
|
||||
if ((long)n2 > this.dataOffset) {
|
||||
throw new IOException("Header overflow: " + n2 + " > " + this.dataOffset);
|
||||
}
|
||||
this.writeBuffer.writeTo(dataOutput, 0, n);
|
||||
dataOutput.writeLong(this.dataOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public void read(DataInput dataInput) throws IOException {
|
||||
this.newStore = false;
|
||||
int n = dataInput.readInt();
|
||||
if (n != 1611526157) {
|
||||
throw new IOException("Invalid or corrupt alarm database.");
|
||||
}
|
||||
this.version = dataInput.readInt();
|
||||
if (this.version != 1) {
|
||||
throw new IOException("Unrecognized alarm db version: " + this.version);
|
||||
}
|
||||
this.recordVersion = dataInput.readInt();
|
||||
this.creationTime = dataInput.readLong();
|
||||
this.pageSize = dataInput.readInt();
|
||||
this.pagesPerBlock = dataInput.readInt();
|
||||
this.dataOffset = dataInput.readLong();
|
||||
}
|
||||
|
||||
public int getRecordVersion() {
|
||||
return this.recordVersion;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return this.pageSize;
|
||||
}
|
||||
|
||||
public int getPagesPerBlock() {
|
||||
return this.pagesPerBlock;
|
||||
}
|
||||
|
||||
public long getDataOffset() {
|
||||
return this.dataOffset;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.newStore = true;
|
||||
}
|
||||
|
||||
public AlarmStoreHeader() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public AlarmStoreHeader(int n) {
|
||||
this.this();
|
||||
this.version = 1;
|
||||
this.creationTime = System.currentTimeMillis();
|
||||
this.pageSize = 512;
|
||||
this.pagesPerBlock = 8;
|
||||
this.recordVersion = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,575 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.platform.BSystemPlatformService
|
||||
* com.tridium.platform.archive.FileArchive
|
||||
* com.tridium.sys.Nre
|
||||
* com.tridium.sys.resource.ResourceReport
|
||||
* com.tridium.sys.service.BServiceEvent
|
||||
* com.tridium.sys.service.ServiceListener
|
||||
* javax.baja.dataRecovery.BIDataRecoveryService
|
||||
* javax.baja.dataRecovery.BIDataRecoverySource
|
||||
* javax.baja.dataRecovery.IDataRecoveryRecord
|
||||
* javax.baja.file.BDirectory
|
||||
* javax.baja.file.BFileSpace
|
||||
* javax.baja.file.BIFile
|
||||
* javax.baja.file.BLocalFileStore
|
||||
* javax.baja.file.FilePath
|
||||
* javax.baja.io.BIEncodable
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.security.AuditEvent
|
||||
* javax.baja.security.Auditor
|
||||
* javax.baja.spy.SpyWriter
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BLong
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.ServiceNotFoundException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.DataRecoveryAlarmEvent;
|
||||
import com.tridium.platform.BSystemPlatformService;
|
||||
import com.tridium.platform.archive.FileArchive;
|
||||
import com.tridium.sys.Nre;
|
||||
import com.tridium.sys.resource.ResourceReport;
|
||||
import com.tridium.sys.service.BServiceEvent;
|
||||
import com.tridium.sys.service.ServiceListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.dataRecovery.BIDataRecoveryService;
|
||||
import javax.baja.dataRecovery.BIDataRecoverySource;
|
||||
import javax.baja.dataRecovery.IDataRecoveryRecord;
|
||||
import javax.baja.file.BDirectory;
|
||||
import javax.baja.file.BFileSpace;
|
||||
import javax.baja.file.BIFile;
|
||||
import javax.baja.file.BLocalFileStore;
|
||||
import javax.baja.file.FilePath;
|
||||
import javax.baja.io.BIEncodable;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.security.AuditEvent;
|
||||
import javax.baja.security.Auditor;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BLong;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFileAlarmDatabase
|
||||
extends BAlarmDatabase
|
||||
implements BIDataRecoverySource {
|
||||
public static final Type TYPE;
|
||||
private static final BOrd ordInSession;
|
||||
private static final String CAPACITY = "capacity";
|
||||
private static final String ARCHIVE_ID = "alarm";
|
||||
private static final Log dataRecoveryLog;
|
||||
private ServiceListener serviceListener;
|
||||
private int capacity;
|
||||
private File dbDir;
|
||||
private File alarmFile;
|
||||
private AlarmStore alarmStore;
|
||||
private BOrd alarmServiceOrd;
|
||||
private BIDataRecoveryService dataRecoveryService;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$file$BFileAlarmDatabase;
|
||||
|
||||
public void doOpen() throws IOException {
|
||||
Object object;
|
||||
if (this.dbDir == null) {
|
||||
try {
|
||||
FilePath filePath;
|
||||
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)Sys.getService((Type)BSystemPlatformService.TYPE);
|
||||
if (bSystemPlatformService.archiveEnabled(ARCHIVE_ID)) {
|
||||
bSystemPlatformService.extractArchive(ARCHIVE_ID);
|
||||
}
|
||||
String string = bSystemPlatformService.getRuntimeDirectory(ARCHIVE_ID);
|
||||
object = (BFileSpace)BOrd.make((String)"file:").get();
|
||||
BIFile bIFile = object.findFile(filePath = new FilePath(string));
|
||||
if (bIFile == null) {
|
||||
BDirectory bDirectory = object.makeDir(filePath);
|
||||
this.dbDir = ((BLocalFileStore)bDirectory.getStore()).getLocalFile();
|
||||
} else {
|
||||
this.dbDir = ((BLocalFileStore)bIFile.getStore()).getLocalFile();
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
if (Sys.getStation() != null) {
|
||||
log.warning("No system platform service available, using station home directory for alarm database root.");
|
||||
this.dbDir = new File(Sys.getBajaHome().getAbsolutePath() + File.separatorChar + "stations" + File.separatorChar + Sys.getStation().getStationName() + File.separatorChar + ARCHIVE_ID);
|
||||
}
|
||||
log.warning("No system platform service available, using Niagara home directory for alarm database root.");
|
||||
this.dbDir = new File(Sys.getBajaHome().getAbsolutePath() + File.separatorChar + ARCHIVE_ID);
|
||||
}
|
||||
}
|
||||
if (!this.dbDir.exists()) {
|
||||
this.dbDir.mkdirs();
|
||||
}
|
||||
this.alarmFile = new File(this.dbDir, "alarm.adb");
|
||||
if (!this.alarmFile.exists()) {
|
||||
this.alarmFile.createNewFile();
|
||||
}
|
||||
int n = 0;
|
||||
while (true) {
|
||||
try {
|
||||
this.alarmStore = new AlarmStore(this.alarmFile, this.capacity);
|
||||
this.alarmStore.open();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Cannot open alarm database.", (Throwable)exception);
|
||||
if (!this.alarmFile.exists() || ++n == 2) break;
|
||||
if (Nre.getPlatform().isFlashFileSystem()) {
|
||||
if (this.alarmFile.delete()) {
|
||||
BAlarmDatabase.log.error("Old alarm database deleted.");
|
||||
continue;
|
||||
}
|
||||
throw new IOException("Unable to delete old alarm database.");
|
||||
}
|
||||
object = this.saveErrorDb();
|
||||
if (object == null) continue;
|
||||
BAlarmDatabase.log.error("Old alarm database saved as " + ((File)object).getAbsolutePath() + '.');
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.alarmServiceOrd = Sys.getService((Type)BAlarmService.TYPE).getOrdInSession();
|
||||
try {
|
||||
this.dataRecoveryService = (BIDataRecoveryService)Sys.getService((Type)BIDataRecoveryService.TYPE);
|
||||
if (!this.dataRecoveryService.isEnabled()) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {}
|
||||
Nre.serviceManager.addServiceListener(this.serviceListener);
|
||||
}
|
||||
|
||||
private final File saveErrorDb() throws IOException {
|
||||
String[] stringArray = this.dbDir.list();
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
if (stringArray[n2].indexOf("error") != -1) {
|
||||
++n;
|
||||
}
|
||||
if (n == 3) {
|
||||
throw new IOException("Cannot create recovery file. " + n + " recovery files already exist.");
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
File file = new File(this.dbDir, "alarm_error.adb");
|
||||
if (file.exists()) {
|
||||
int n3 = 2;
|
||||
while (file.exists()) {
|
||||
file = new File(this.dbDir, "alarm_error" + n3 + ".adb");
|
||||
++n3;
|
||||
}
|
||||
}
|
||||
if (!this.alarmFile.renameTo(file)) {
|
||||
throw new IOException("Unable to create recovery file.");
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public void doSave() throws IOException {
|
||||
try {
|
||||
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)Sys.getService((Type)BSystemPlatformService.TYPE);
|
||||
if (bSystemPlatformService.archiveEnabled(ARCHIVE_ID)) {
|
||||
FileArchive fileArchive = bSystemPlatformService.createFileArchive(ARCHIVE_ID);
|
||||
String string = this.dbDir.getAbsolutePath();
|
||||
String string2 = this.alarmFile.getAbsolutePath().substring(string.length() + 1);
|
||||
fileArchive.writeFile(this.alarmFile, string2);
|
||||
fileArchive.close();
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
log.error("No system platform service available, cannot create alarm archive file.");
|
||||
throw new IOException("Could not create alarm archive file.");
|
||||
}
|
||||
}
|
||||
|
||||
public void doFlush() throws IOException {
|
||||
this.alarmStore.flush();
|
||||
}
|
||||
|
||||
public void doClose() {
|
||||
this.alarmStore.close();
|
||||
this.alarmStore = null;
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)bAlarmRecord.getUuid(), new DataRecoveryAlarmEvent.Append(bAlarmRecord).encode());
|
||||
}
|
||||
this.alarmStore.append(bAlarmRecord);
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.update((BIDataRecoverySource)this, (BIEncodable)bAlarmRecord.getUuid(), new DataRecoveryAlarmEvent.Update(bAlarmRecord).encode());
|
||||
}
|
||||
this.alarmStore.update(bAlarmRecord);
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getRecordCount();
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord getRecord(BUuid bUuid) throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getRecord(bUuid);
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.scan();
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.timeQuery(bAbsTime, bAbsTime2);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getAlarmsForSource(bOrdList);
|
||||
}
|
||||
|
||||
public synchronized Cursor getOpenAlarms() throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getOpenAlarms();
|
||||
}
|
||||
|
||||
public synchronized Cursor getAckPendingAlarms() throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getAckPendingAlarms();
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BString.make((String)"clearAll"), new DataRecoveryAlarmEvent.ClearAll().encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearAllRecords(context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear", Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BLong.make((long)Clock.ticks()), new DataRecoveryAlarmEvent.ClearOld(bAbsTime).encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearOldRecords(bAbsTime, context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear before " + bAbsTime.toString((Context)BAlarmRecord.TIMESTAMP_FACETS), Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
if (bUuid == null || bUuid.isNull()) {
|
||||
return;
|
||||
}
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)bUuid, new DataRecoveryAlarmEvent.ClearRecord(bUuid).encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearRecord(bUuid, context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear record " + bUuid, Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public void setCapacity(int n) throws IOException {
|
||||
if (this.capacity == n) {
|
||||
return;
|
||||
}
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BString.make((String)CAPACITY), new DataRecoveryAlarmEvent.CapacityChange(n).encode());
|
||||
}
|
||||
this.capacity = n;
|
||||
if (!this.isOpen()) {
|
||||
return;
|
||||
}
|
||||
this.alarmStore.setCapacity(this.capacity);
|
||||
this.alarmStore.trimToCapacity();
|
||||
}
|
||||
|
||||
public BOrd getOrdInSession() throws Exception {
|
||||
return ordInSession;
|
||||
}
|
||||
|
||||
public void dataRecoveryRestoreComplete() {
|
||||
}
|
||||
|
||||
public boolean dataRecoveryRestore(IDataRecoveryRecord iDataRecoveryRecord) throws Exception {
|
||||
DataRecoveryAlarmEvent dataRecoveryAlarmEvent = null;
|
||||
try {
|
||||
dataRecoveryAlarmEvent = DataRecoveryAlarmEvent.make(iDataRecoveryRecord.getData());
|
||||
dataRecoveryAlarmEvent.execute(this);
|
||||
if (dataRecoveryLog.isTraceOn()) {
|
||||
dataRecoveryLog.trace("Restored alarm event " + dataRecoveryAlarmEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (dataRecoveryAlarmEvent == null) {
|
||||
dataRecoveryLog.error("Could not restore event", (Throwable)exception);
|
||||
} else {
|
||||
dataRecoveryLog.error("Could not restore event " + dataRecoveryAlarmEvent, (Throwable)exception);
|
||||
}
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
public void dataRecoverySpy(SpyWriter spyWriter, Iterator iterator) throws Exception {
|
||||
Object object;
|
||||
Object object2;
|
||||
IDataRecoveryRecord iDataRecoveryRecord;
|
||||
DataRecoveryAlarmEvent dataRecoveryAlarmEvent = null;
|
||||
HashMap<Object, DataRecoveryAlarmSpyData> hashMap = new HashMap<Object, DataRecoveryAlarmSpyData>();
|
||||
int n = 0;
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
++n;
|
||||
iDataRecoveryRecord = (IDataRecoveryRecord)iterator.next();
|
||||
dataRecoveryAlarmEvent = DataRecoveryAlarmEvent.make(iDataRecoveryRecord.getData());
|
||||
object2 = new Integer(dataRecoveryAlarmEvent.getEventCode());
|
||||
object = (DataRecoveryAlarmSpyData)hashMap.get(object2);
|
||||
if (object == null) {
|
||||
hashMap.put(object2, new DataRecoveryAlarmSpyData(iDataRecoveryRecord.getData().length));
|
||||
continue;
|
||||
}
|
||||
hashMap.put(object2, ((DataRecoveryAlarmSpyData)object).addEvent(iDataRecoveryRecord.getData().length));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
iDataRecoveryRecord = hashMap.keySet().iterator();
|
||||
object2 = n + " Alarm Events Recently Recorded in Data Recovery";
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle(object2, 4);
|
||||
spyWriter.w((Object)"<tr><th>Event</th><th>Occurrences</th><th>Total Bytes</th><th>Avg Bytes</th></tr>\n");
|
||||
while (iDataRecoveryRecord.hasNext()) {
|
||||
try {
|
||||
String string;
|
||||
object = (Integer)iDataRecoveryRecord.next();
|
||||
DataRecoveryAlarmSpyData dataRecoveryAlarmSpyData = (DataRecoveryAlarmSpyData)hashMap.get(object);
|
||||
switch ((Integer)object) {
|
||||
case 0: {
|
||||
string = "Append";
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
string = "Update";
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
string = "ClearAll";
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
string = "ClearOld";
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
string = "ClearRecord";
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
string = "CapacityChange";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new IllegalStateException("Unknown alarm event code: '" + object + '\'');
|
||||
}
|
||||
}
|
||||
spyWriter.tr((Object)string, (Object)("" + dataRecoveryAlarmSpyData.occurances), (Object)("" + dataRecoveryAlarmSpyData.totalBytes), (Object)("" + (double)dataRecoveryAlarmSpyData.totalBytes / (double)dataRecoveryAlarmSpyData.occurances));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
|
||||
private final BIDataRecoveryService getDataRecoveryService() {
|
||||
if (this.dataRecoveryService == null) {
|
||||
try {
|
||||
this.dataRecoveryService = (BIDataRecoveryService)Sys.getService((Type)BIDataRecoveryService.TYPE);
|
||||
if (!this.dataRecoveryService.isEnabled()) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return this.dataRecoveryService;
|
||||
}
|
||||
|
||||
public final Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
switch (n) {
|
||||
case 21: {
|
||||
((ResourceReport)object).add(ARCHIVE_ID, this.countResourceUnits());
|
||||
break;
|
||||
}
|
||||
case 602: {
|
||||
return this.alarmStore;
|
||||
}
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
private final int countResourceUnits() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void main(String[] stringArray) throws Exception {
|
||||
try {
|
||||
String string = stringArray[0];
|
||||
if (string.equals("o")) {
|
||||
BFileAlarmDatabase bFileAlarmDatabase = new BFileAlarmDatabase();
|
||||
bFileAlarmDatabase.open();
|
||||
System.out.println("Done.");
|
||||
bFileAlarmDatabase.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.serviceListener = new ServiceListener(){
|
||||
|
||||
public final void serviceEvent(BServiceEvent bServiceEvent) {
|
||||
if (bServiceEvent.getServiceType().is(BIDataRecoveryService.TYPE)) {
|
||||
if (bServiceEvent.getId() == 0) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = (BIDataRecoveryService)bServiceEvent.getService();
|
||||
if (!BFileAlarmDatabase.this.dataRecoveryService.isEnabled()) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = null;
|
||||
}
|
||||
} else if (bServiceEvent.getId() == 1) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return "ServiceListener for AlarmService";
|
||||
}
|
||||
};
|
||||
this.capacity = 10000;
|
||||
this.dbDir = null;
|
||||
this.alarmFile = null;
|
||||
this.alarmStore = null;
|
||||
this.alarmServiceOrd = null;
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
|
||||
public BFileAlarmDatabase() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$file$BFileAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$file$BFileAlarmDatabase = BFileAlarmDatabase.class("[Lcom.tridium.alarm.db.file.BFileAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
ordInSession = BOrd.make((String)"alarm:");
|
||||
dataRecoveryLog = Log.getLog((String)"alarm.dataRecovery");
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class DataRecoveryAlarmSpyData {
|
||||
int occurances;
|
||||
int totalBytes;
|
||||
|
||||
public DataRecoveryAlarmSpyData addEvent(int n) {
|
||||
++this.occurances;
|
||||
this.totalBytes += n;
|
||||
return this;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.occurances = -1;
|
||||
this.totalBytes = -1;
|
||||
}
|
||||
|
||||
public DataRecoveryAlarmSpyData(int n) {
|
||||
this.this();
|
||||
this.occurances = 1;
|
||||
this.totalBytes = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Block {
|
||||
private AlarmStore store;
|
||||
private int index;
|
||||
private byte[] data;
|
||||
private Page[] pages;
|
||||
private Input in;
|
||||
private Output out;
|
||||
private boolean dirty;
|
||||
Block prev;
|
||||
Block next;
|
||||
|
||||
public int getSize() {
|
||||
return this.data.length;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return this.dirty;
|
||||
}
|
||||
|
||||
public void clear() throws IOException {
|
||||
int n = 0;
|
||||
while (n < this.pages.length) {
|
||||
this.pages[n] = new Page(this, n, this.store.getHeader().getPageSize());
|
||||
this.pages[n].clear();
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public void read(DataInput dataInput) throws IOException {
|
||||
dataInput.readFully(this.data);
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.write(this.data);
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public synchronized Page getPage(int n) throws IOException {
|
||||
if (this.pages == null) {
|
||||
this.pages = new Page[this.store.getHeader().getPagesPerBlock()];
|
||||
}
|
||||
try {
|
||||
if (this.pages[n] == null) {
|
||||
this.pages[n] = this.initPage(n);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
|
||||
int n2 = this.store.getHeader().getPagesPerBlock();
|
||||
throw new IllegalArgumentException("Invalid page index: " + n + ". Pages per block = " + n2);
|
||||
}
|
||||
return this.pages[n];
|
||||
}
|
||||
|
||||
private final Page initPage(int n) throws IOException {
|
||||
Page page = new Page(this, n, this.store.getHeader().getPageSize());
|
||||
page.read();
|
||||
return page;
|
||||
}
|
||||
|
||||
public void dump() throws IOException {
|
||||
int n = this.store.getHeader().getPagesPerBlock();
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
Page page = this.getPage(n2);
|
||||
System.out.println(n2 + "] " + page.getPageOfRecord() + " of " + page.getPagesOfRecord());
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
|
||||
public Input getInput() {
|
||||
return this.in;
|
||||
}
|
||||
|
||||
public int write(int n, int n2) {
|
||||
this.data[n] = (byte)n2;
|
||||
this.dirty = true;
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
public int write(int n, byte[] byArray, int n2, int n3) {
|
||||
System.arraycopy(byArray, n2, this.data, n, n3);
|
||||
this.dirty = true;
|
||||
return n + n3;
|
||||
}
|
||||
|
||||
public int writeInt(int n, int n2) {
|
||||
this.write(n++, n2 >>> 24 & 0xFF);
|
||||
this.write(n++, n2 >>> 16 & 0xFF);
|
||||
this.write(n++, n2 >>> 8 & 0xFF);
|
||||
this.write(n++, n2 & 0xFF);
|
||||
return n;
|
||||
}
|
||||
|
||||
public Output getOutput() {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public Block(AlarmStore alarmStore, int n) {
|
||||
this.this();
|
||||
this.store = alarmStore;
|
||||
this.index = n;
|
||||
int n2 = alarmStore.getHeader().getPageSize();
|
||||
int n3 = alarmStore.getHeader().getPagesPerBlock();
|
||||
this.data = new byte[n2 * n3];
|
||||
this.pages = new Page[n3];
|
||||
this.out = new Output(this);
|
||||
this.in = new Input(this.data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Output {
|
||||
private Block block;
|
||||
private int pos;
|
||||
|
||||
public void seek(int n) {
|
||||
this.pos = n;
|
||||
}
|
||||
|
||||
public void write(int n) {
|
||||
this.block.write(this.pos++, n);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray) {
|
||||
this.pos = this.block.write(this.pos, byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray, int n, int n2) {
|
||||
this.pos = this.block.write(this.pos, byArray, n, n2);
|
||||
}
|
||||
|
||||
public void writeInt(int n) {
|
||||
this.pos = this.block.writeInt(this.pos, n);
|
||||
}
|
||||
|
||||
public Output(Block block2) {
|
||||
this.block = block2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Input {
|
||||
private byte[] buffer;
|
||||
private int length;
|
||||
private int pos;
|
||||
|
||||
public void seek(int n) {
|
||||
this.pos = n;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
try {
|
||||
return this.buffer[this.pos++] & 0xFF;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
|
||||
throw new EOFException();
|
||||
}
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3 = Math.min(n2, this.length - this.pos);
|
||||
if (n3 == 0) {
|
||||
return -1;
|
||||
}
|
||||
System.arraycopy(this.buffer, this.pos, byArray, n, n3);
|
||||
this.pos += n3;
|
||||
return n3;
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray) throws IOException {
|
||||
this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray, int n, int n2) throws IOException {
|
||||
this.read(byArray, n, n2);
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
return (this.read() << 24) + (this.read() << 16) + (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public Input(byte[] byArray) {
|
||||
this.buffer = byArray;
|
||||
this.length = byArray.length;
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.IntHashMap
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import java.io.IOException;
|
||||
import javax.baja.nre.util.IntHashMap;
|
||||
|
||||
public class BlockCache {
|
||||
private AlarmStore store;
|
||||
private int max;
|
||||
private int size;
|
||||
private IntHashMap table;
|
||||
private Block newest;
|
||||
private Block oldest;
|
||||
|
||||
public synchronized Block getBlock(int n) {
|
||||
return (Block)this.table.get(n);
|
||||
}
|
||||
|
||||
public synchronized void add(Block block) throws IOException {
|
||||
int n = block.getIndex();
|
||||
Block block2 = (Block)this.table.get(n);
|
||||
if (block2 != null) {
|
||||
if (block2.prev != null) {
|
||||
block2.prev.next = block2.next;
|
||||
}
|
||||
if (block2.next != null) {
|
||||
block2.next.prev = block2.prev;
|
||||
}
|
||||
if (block2 == this.newest) {
|
||||
this.newest = block2.next;
|
||||
}
|
||||
if (block2 == this.oldest) {
|
||||
this.oldest = block2.prev;
|
||||
}
|
||||
block2.next = null;
|
||||
block2.prev = null;
|
||||
--this.size;
|
||||
}
|
||||
this.table.put(n, (Object)block);
|
||||
if (this.newest == null) {
|
||||
this.newest = this.oldest = block;
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
} else {
|
||||
this.newest.prev = block;
|
||||
block.next = this.newest;
|
||||
block.prev = null;
|
||||
this.newest = block;
|
||||
}
|
||||
++this.size;
|
||||
if (this.size > this.max) {
|
||||
this.evict(this.size - this.max);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(int n) {
|
||||
Block block = (Block)this.table.get(n);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
this.table.remove(n);
|
||||
if (block.prev != null) {
|
||||
block.prev.next = block.next;
|
||||
}
|
||||
if (block.next != null) {
|
||||
block.next.prev = block.prev;
|
||||
}
|
||||
if (block == this.newest) {
|
||||
this.newest = block.next;
|
||||
}
|
||||
if (block == this.oldest) {
|
||||
this.oldest = block.prev;
|
||||
}
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public synchronized void remove(Block block) {
|
||||
this.remove(block.getIndex());
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
Block block = this.newest;
|
||||
while (block != null) {
|
||||
this.store.writeBlock(block);
|
||||
block = block.next;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void evict(int n) throws IOException {
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if (this.size == 0) {
|
||||
return;
|
||||
}
|
||||
this.store.writeBlock(this.oldest);
|
||||
this.table.remove(this.oldest.getIndex());
|
||||
if (this.newest == this.oldest) {
|
||||
this.oldest = null;
|
||||
this.newest = null;
|
||||
} else {
|
||||
Block block = this.oldest;
|
||||
this.oldest = this.oldest.prev;
|
||||
this.oldest.next = null;
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
}
|
||||
--this.size;
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
System.out.println("BlockCache.dump");
|
||||
System.out.println(" forward");
|
||||
int n = 0;
|
||||
Block block = this.newest;
|
||||
while (block != null) {
|
||||
System.out.print(" " + n++ + ") block " + block.getIndex());
|
||||
if (block == this.oldest) {
|
||||
System.out.print(" (oldest)");
|
||||
}
|
||||
if (block == this.newest) {
|
||||
System.out.print(" (newest)");
|
||||
}
|
||||
System.out.println();
|
||||
block = block.next;
|
||||
}
|
||||
System.out.println(" reverse");
|
||||
--n;
|
||||
block = this.oldest;
|
||||
while (block != null) {
|
||||
System.out.print(" " + n-- + ") block " + block.getIndex());
|
||||
if (block == this.oldest) {
|
||||
System.out.print(" (oldest)");
|
||||
}
|
||||
if (block == this.newest) {
|
||||
System.out.print(" (newest)");
|
||||
}
|
||||
System.out.println();
|
||||
block = block.prev;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockCache(AlarmStore alarmStore, int n) {
|
||||
this.store = alarmStore;
|
||||
this.max = n;
|
||||
this.table = new IntHashMap(this.max);
|
||||
this.size = 0;
|
||||
this.newest = null;
|
||||
this.oldest = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.dataRecovery.DataRecoveryException
|
||||
* javax.baja.io.ByteBuffer
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.BFileAlarmDatabase;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.dataRecovery.DataRecoveryException;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public abstract class DataRecoveryAlarmEvent {
|
||||
static final byte EVENT_APPEND = 0;
|
||||
static final byte EVENT_UPDATE = 1;
|
||||
static final byte EVENT_CLEARALL = 2;
|
||||
static final byte EVENT_CLEAROLD = 3;
|
||||
static final byte EVENT_CLEARRECORD = 4;
|
||||
static final byte EVENT_CAPACITYCHANGE = 5;
|
||||
private int eventCode;
|
||||
|
||||
public static final DataRecoveryAlarmEvent make(byte[] byArray) throws Exception {
|
||||
ByteBuffer byteBuffer = new ByteBuffer(byArray);
|
||||
int n = -1;
|
||||
try {
|
||||
n = byteBuffer.readByte();
|
||||
switch (n) {
|
||||
case 0: {
|
||||
return new Append(byteBuffer);
|
||||
}
|
||||
case 1: {
|
||||
return new Update(byteBuffer);
|
||||
}
|
||||
case 2: {
|
||||
return new ClearAll(byteBuffer);
|
||||
}
|
||||
case 3: {
|
||||
return new ClearOld(byteBuffer);
|
||||
}
|
||||
case 4: {
|
||||
return new ClearRecord(byteBuffer);
|
||||
}
|
||||
case 5: {
|
||||
return new CapacityChange(byteBuffer);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unknown alarm event code: '" + n + '\'');
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
throw new DataRecoveryException("Invalid alarm data (event=" + n + ", length=" + byArray.length + ')', (Throwable)iOException);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void execute(BFileAlarmDatabase var1) throws Exception;
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.writeByte(this.eventCode);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
protected final AlarmStore getAlarmStore(BFileAlarmDatabase bFileAlarmDatabase) {
|
||||
return (AlarmStore)bFileAlarmDatabase.fw(602, null, null, null, null);
|
||||
}
|
||||
|
||||
int getEventCode() {
|
||||
return this.eventCode;
|
||||
}
|
||||
|
||||
private DataRecoveryAlarmEvent(int n) {
|
||||
this.eventCode = n;
|
||||
}
|
||||
|
||||
public static class Append
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAlarmRecord record;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
BAlarmRecord bAlarmRecord = alarmStore.getRecord(this.record.getUuid());
|
||||
if (bAlarmRecord == null || bAlarmRecord.getLastUpdate().isBefore(this.record.getLastUpdate())) {
|
||||
this.getAlarmStore(bFileAlarmDatabase).append(this.record);
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).ackAlarm(this.record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.record.write((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Append ");
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
stringBuffer.append("and Route ");
|
||||
}
|
||||
stringBuffer.append(this.record.getUuid()).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public Append(BAlarmRecord bAlarmRecord) {
|
||||
super(0);
|
||||
this.record = bAlarmRecord;
|
||||
}
|
||||
|
||||
public Append(ByteBuffer byteBuffer) throws Exception {
|
||||
super(0);
|
||||
this.record = new BAlarmRecord();
|
||||
this.record.read((DataInput)byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Update
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAlarmRecord record;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
BAlarmRecord bAlarmRecord = alarmStore.getRecord(this.record.getUuid());
|
||||
if (bAlarmRecord == null || bAlarmRecord.getLastUpdate().isBefore(this.record.getLastUpdate())) {
|
||||
this.getAlarmStore(bFileAlarmDatabase).update(this.record);
|
||||
if (bAlarmRecord != null && bAlarmRecord.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).ackAlarm(this.record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.record.write((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Update ");
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
stringBuffer.append("and Route ");
|
||||
}
|
||||
stringBuffer.append(this.record.getUuid()).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public Update(BAlarmRecord bAlarmRecord) {
|
||||
super(1);
|
||||
this.record = bAlarmRecord;
|
||||
}
|
||||
|
||||
public Update(ByteBuffer byteBuffer) throws Exception {
|
||||
super(1);
|
||||
this.record = new BAlarmRecord();
|
||||
this.record.read((DataInput)byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearAll
|
||||
extends DataRecoveryAlarmEvent {
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearAllRecords(null);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[ClearAll]";
|
||||
}
|
||||
|
||||
public ClearAll() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
public ClearAll(ByteBuffer byteBuffer) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearOld
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAbsTime before;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearOldRecords(this.before, null);
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.before.encode((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[ClearOld ").append(this.before).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public ClearOld(BAbsTime bAbsTime) {
|
||||
super(3);
|
||||
this.before = bAbsTime;
|
||||
}
|
||||
|
||||
public ClearOld(ByteBuffer byteBuffer) throws Exception {
|
||||
this(BAbsTime.make((long)byteBuffer.readLong()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearRecord
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BUuid uuid;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearRecord(this.uuid, null);
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.uuid.encode((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[ClearRecord ").append(this.uuid).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public ClearRecord(BUuid bUuid) {
|
||||
super(4);
|
||||
this.uuid = bUuid;
|
||||
}
|
||||
|
||||
public ClearRecord(ByteBuffer byteBuffer) throws IOException {
|
||||
this((BUuid)BUuid.DEFAULT.decode((DataInput)byteBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
public static class CapacityChange
|
||||
extends DataRecoveryAlarmEvent {
|
||||
int capacity;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
alarmStore.setCapacity(this.capacity);
|
||||
alarmStore.trimToCapacity();
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
byteBuffer.writeInt(this.capacity);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Capacity ").append(this.capacity).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public CapacityChange(int n) {
|
||||
super(5);
|
||||
this.capacity = n;
|
||||
}
|
||||
|
||||
public CapacityChange(ByteBuffer byteBuffer) throws Exception {
|
||||
this(byteBuffer.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
public class FreePageMap {
|
||||
private static final int[] BIT_MASKS = new int[]{1, 2, 4, 8, 16, 32, 64, 128};
|
||||
private int pageCount = 0;
|
||||
private byte[] pageMask = null;
|
||||
|
||||
public int getPageCount() {
|
||||
return this.pageCount;
|
||||
}
|
||||
|
||||
public int getFreeCount() {
|
||||
int n;
|
||||
int n2;
|
||||
byte by;
|
||||
if (this.pageCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < this.pageMask.length - 1) {
|
||||
by = this.pageMask[n4];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < 8) {
|
||||
if ((by & n2) == 0) {
|
||||
++n3;
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
n4 = this.pageCount - (this.pageMask.length - 1) * 8;
|
||||
by = this.pageMask[this.pageMask.length - 1];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < n4) {
|
||||
if ((by & n2) == 0) {
|
||||
++n3;
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
return n3;
|
||||
}
|
||||
|
||||
public int getFreePage() {
|
||||
if (this.pageCount != 0) {
|
||||
int n = this.pageMask.length;
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if ((this.pageMask[n2] & 0xFF ^ 0xFF) != 0) {
|
||||
int n3 = 1;
|
||||
int n4 = 0;
|
||||
while (n4 < 8) {
|
||||
if ((this.pageMask[n2] & 0xFF & n3) == 0) {
|
||||
return n2 * 8 + n4;
|
||||
}
|
||||
n3 <<= 1;
|
||||
++n4;
|
||||
}
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean isFree(int n) {
|
||||
int n2 = n / 8;
|
||||
if (n2 >= this.pageCount) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
boolean bl = false;
|
||||
if ((this.pageMask[n2] & BIT_MASKS[n - n2 * 8]) == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public void setFree(int n, boolean bl) {
|
||||
if (n >= this.pageCount) {
|
||||
this.addFreePages(n - this.pageCount + 1);
|
||||
}
|
||||
int n2 = n / 8;
|
||||
int n3 = BIT_MASKS[n - n2 * 8];
|
||||
this.pageMask[n2] = bl ? (byte)(this.pageMask[n2] & ~n3) : (byte)(this.pageMask[n2] | n3);
|
||||
}
|
||||
|
||||
public void addFreePages(int n) {
|
||||
int n2;
|
||||
if (n < 0) {
|
||||
throw new IllegalArgumentException("Invalid add count: " + n);
|
||||
}
|
||||
if (this.pageMask == null) {
|
||||
int n3 = n / 8;
|
||||
if (n % 8 != 0) {
|
||||
++n3;
|
||||
}
|
||||
this.pageMask = new byte[n3];
|
||||
this.pageCount = n;
|
||||
return;
|
||||
}
|
||||
int n4 = this.pageMask.length * 8;
|
||||
int n5 = n4 - this.pageCount;
|
||||
if (n5 != 0) {
|
||||
n2 = n5 > n ? n : n5;
|
||||
this.pageCount += n2;
|
||||
n -= n2;
|
||||
}
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
n2 = n / 8;
|
||||
if (n % 8 != 0) {
|
||||
++n2;
|
||||
}
|
||||
int n6 = this.pageMask.length;
|
||||
byte[] byArray = new byte[n6 + n2];
|
||||
System.arraycopy(this.pageMask, 0, byArray, 0, n6);
|
||||
this.pageMask = byArray;
|
||||
this.pageCount += n;
|
||||
}
|
||||
|
||||
public int getSizeInBytes() {
|
||||
return this.pageMask.length;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
int n;
|
||||
int n2;
|
||||
byte by;
|
||||
if (this.pageCount == 0) {
|
||||
return;
|
||||
}
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < this.pageMask.length - 1) {
|
||||
by = this.pageMask[n4];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < 8) {
|
||||
if ((by & n2) == 0) {
|
||||
System.out.println(n3++ + ") free");
|
||||
} else {
|
||||
System.out.println(n3++ + ") in use");
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
n4 = this.pageCount - (this.pageMask.length - 1) * 8;
|
||||
by = this.pageMask[this.pageMask.length - 1];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < n4) {
|
||||
if ((by & n2) == 0) {
|
||||
System.out.println(n3++ + ") free");
|
||||
} else {
|
||||
System.out.println(n3++ + ") in use");
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class IndexEntry {
|
||||
public static final int FLAG_OPEN = 1;
|
||||
public static final int FLAG_ACKED = 2;
|
||||
public static final int FLAG_NORMAL = 4;
|
||||
public static final int FLAG_ACK_PENDING = 8;
|
||||
public final BAbsTime timestamp;
|
||||
public final int pageIndex;
|
||||
public IndexEntry[] nextTimestamp;
|
||||
public IndexEntry prevTimestamp;
|
||||
public IndexEntry[] nextSource;
|
||||
public IndexEntry prevSource;
|
||||
public byte flags;
|
||||
public IndexEntry prevOpen;
|
||||
public IndexEntry nextOpen;
|
||||
public IndexEntry prevAckPending;
|
||||
public IndexEntry nextAckPending;
|
||||
|
||||
public boolean equals(Object object) {
|
||||
IndexEntry indexEntry = (IndexEntry)object;
|
||||
if (this.timestamp == null && indexEntry.timestamp == null) {
|
||||
return true;
|
||||
}
|
||||
if (this.timestamp == null || indexEntry.timestamp == null) {
|
||||
return false;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.timestamp.equals((Object)indexEntry.timestamp) && this.pageIndex == indexEntry.pageIndex) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean isOpen() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 1) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setOpen(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 1) : (byte)(this.flags & 0xFFFFFFFE);
|
||||
}
|
||||
|
||||
public final boolean isAcked() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 2) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setAcked(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 2) : (byte)(this.flags & 0xFFFFFFFD);
|
||||
}
|
||||
|
||||
public final boolean isNormal() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 4) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setNormal(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 4) : (byte)(this.flags & 0xFFFFFFFB);
|
||||
}
|
||||
|
||||
public final boolean isAckPending() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 8) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setAckPending(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 8) : (byte)(this.flags & 0xFFFFFFF7);
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.flags = 0;
|
||||
}
|
||||
|
||||
public IndexEntry() {
|
||||
this.this();
|
||||
this.timestamp = null;
|
||||
this.pageIndex = -1;
|
||||
}
|
||||
|
||||
public IndexEntry(BAlarmRecord bAlarmRecord, int n) {
|
||||
this.this();
|
||||
this.timestamp = bAlarmRecord.getTimestamp();
|
||||
this.pageIndex = n;
|
||||
}
|
||||
|
||||
public IndexEntry(BAbsTime bAbsTime, int n) {
|
||||
this.this();
|
||||
this.timestamp = bAbsTime;
|
||||
this.pageIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class OpenIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private IndexEntry first = null;
|
||||
private IndexEntry last = null;
|
||||
private int size = 0;
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public void add(IndexEntry indexEntry) {
|
||||
if (indexEntry.isOpen()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setOpen(true);
|
||||
indexEntry.nextOpen = null;
|
||||
indexEntry.prevOpen = null;
|
||||
if (this.size == 0) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
IndexEntry indexEntry2 = indexEntry.prevTimestamp;
|
||||
while (indexEntry2 != null && !indexEntry2.isOpen()) {
|
||||
indexEntry2 = indexEntry2.prevTimestamp;
|
||||
}
|
||||
if (indexEntry2 == null) {
|
||||
if (this.first == null) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
indexEntry.nextOpen = this.first;
|
||||
this.first.prevOpen = indexEntry;
|
||||
this.first = indexEntry;
|
||||
}
|
||||
} else {
|
||||
indexEntry.nextOpen = indexEntry2.nextOpen;
|
||||
indexEntry.prevOpen = indexEntry2;
|
||||
if (indexEntry2.nextOpen != null) {
|
||||
indexEntry2.nextOpen.prevOpen = indexEntry;
|
||||
}
|
||||
indexEntry2.nextOpen = indexEntry;
|
||||
if (indexEntry.prevOpen == this.last) {
|
||||
this.last = indexEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0 || indexEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (!indexEntry.isOpen()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setOpen(false);
|
||||
if (indexEntry.prevOpen != null) {
|
||||
indexEntry.prevOpen.nextOpen = indexEntry.nextOpen;
|
||||
}
|
||||
if (indexEntry.nextOpen != null) {
|
||||
indexEntry.nextOpen.prevOpen = indexEntry.prevOpen;
|
||||
}
|
||||
if (indexEntry == this.first) {
|
||||
this.first = indexEntry.nextOpen;
|
||||
}
|
||||
if (indexEntry == this.last) {
|
||||
this.last = indexEntry.prevOpen;
|
||||
}
|
||||
indexEntry.nextOpen = null;
|
||||
indexEntry.prevOpen = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
IndexEntry indexEntry = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ") " + indexEntry.timestamp.toString((Context)showSecs) + " open=" + indexEntry.isOpen());
|
||||
indexEntry = indexEntry.nextOpen;
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isAfter(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is before " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isOpen()) {
|
||||
throw new IllegalStateException("Cleared alarm in open index, ascending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.nextOpen;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry = null;
|
||||
indexEntry2 = this.last;
|
||||
n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isBefore(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is after " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isOpen()) {
|
||||
throw new IllegalStateException("Cleared alarm in open index, descending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.prevOpen;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Page {
|
||||
public static final int HEADER_SIZE = 12;
|
||||
private Block block;
|
||||
private int pageInBlock;
|
||||
private int size;
|
||||
private int recPage;
|
||||
private int recPages;
|
||||
private int nextPage;
|
||||
|
||||
public int getPageOfRecord() {
|
||||
return this.recPage;
|
||||
}
|
||||
|
||||
public int getPagesOfRecord() {
|
||||
return this.recPages;
|
||||
}
|
||||
|
||||
public int getNextPage() {
|
||||
return this.nextPage;
|
||||
}
|
||||
|
||||
public synchronized void read() throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock);
|
||||
this.recPage = input.readInt();
|
||||
this.recPages = input.readInt();
|
||||
this.nextPage = input.readInt();
|
||||
}
|
||||
|
||||
public synchronized void write(int n, int n2, int n3, byte[] byArray, int n4, int n5) throws IOException {
|
||||
this.recPage = n;
|
||||
this.recPages = n2;
|
||||
this.nextPage = n3;
|
||||
Block.Output output = this.block.getOutput();
|
||||
output.seek(this.size * this.pageInBlock);
|
||||
output.writeInt(n);
|
||||
output.writeInt(n2);
|
||||
output.writeInt(n3);
|
||||
if (n5 != 0) {
|
||||
output.write(byArray, n4, n5);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() throws IOException {
|
||||
this.write(-1, 0, -1, null, 0, 0);
|
||||
}
|
||||
|
||||
public synchronized int readData(int n) throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock + 12 + n);
|
||||
return input.read();
|
||||
}
|
||||
|
||||
public synchronized int readData(int n, byte[] byArray, int n2, int n3) throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock + 12 + n);
|
||||
int n4 = this.size - 12 - n;
|
||||
if (n4 < n3) {
|
||||
return input.read(byArray, n2, n4);
|
||||
}
|
||||
return input.read(byArray, n2, n3);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.recPage + " of " + this.recPages + ", next=" + this.nextPage;
|
||||
}
|
||||
|
||||
public Page(Block block, int n, int n2) {
|
||||
this.block = block;
|
||||
this.pageInBlock = n;
|
||||
this.size = n2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import java.io.DataInput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.UTFDataFormatException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class PageReader
|
||||
implements DataInput {
|
||||
private AlarmStore store;
|
||||
private int pageIndex;
|
||||
private Page page;
|
||||
private int pos;
|
||||
private int pageLen;
|
||||
private int[] pages;
|
||||
private int pageCount;
|
||||
|
||||
public void init(int n) throws IOException {
|
||||
this.pageIndex = n;
|
||||
if (this.pageIndex != -1) {
|
||||
this.page = this.store.readPage(this.pageIndex);
|
||||
}
|
||||
this.pos = 0;
|
||||
this.pageLen = this.store.getHeader().getPageSize() - 12;
|
||||
this.pageCount = 1;
|
||||
if (this.pages == null) {
|
||||
this.pages = new int[3];
|
||||
}
|
||||
this.pages[0] = n;
|
||||
}
|
||||
|
||||
private final void nextPage() throws IOException {
|
||||
if (this.page == null) {
|
||||
throw new IllegalStateException("PageReader has not been initialized.");
|
||||
}
|
||||
int n = this.page.getNextPage();
|
||||
if (n == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
this.pageIndex = n;
|
||||
this.page = this.store.readPage(this.pageIndex);
|
||||
this.pos = 0;
|
||||
if (this.pageCount == this.pages.length) {
|
||||
int[] nArray = new int[this.pageCount + 1];
|
||||
System.arraycopy(this.pages, 0, nArray, 0, this.pageCount);
|
||||
this.pages = nArray;
|
||||
}
|
||||
this.pages[this.pageCount++] = this.pageIndex;
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
return this.pageCount;
|
||||
}
|
||||
|
||||
public int getPageIndex(int n) {
|
||||
return this.pages[n];
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (this.pos >= this.pageLen) {
|
||||
this.nextPage();
|
||||
}
|
||||
return this.page.readData(this.pos++);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
if (this.pos >= this.pageLen) {
|
||||
this.nextPage();
|
||||
}
|
||||
int n3 = this.page.readData(this.pos, byArray, n, n2);
|
||||
this.pos += n3;
|
||||
return n3;
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray) throws IOException {
|
||||
this.readFully(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3 = n2;
|
||||
int n4 = 0;
|
||||
while (n4 < n3) {
|
||||
int n5 = this.read(byArray, n + n4, n3 - n4);
|
||||
if (n5 == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
n4 += n5;
|
||||
}
|
||||
}
|
||||
|
||||
public int skipBytes(int n) throws IOException {
|
||||
int n2 = n;
|
||||
while (n > 0) {
|
||||
int n3 = this.pageLen - this.pos;
|
||||
if (n3 > n) {
|
||||
this.pos += n;
|
||||
return n2;
|
||||
}
|
||||
n -= n3;
|
||||
this.nextPage();
|
||||
}
|
||||
return n2;
|
||||
}
|
||||
|
||||
public boolean readBoolean() throws IOException {
|
||||
boolean bl = false;
|
||||
if (this.read() != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public byte readByte() throws IOException {
|
||||
return (byte)this.read();
|
||||
}
|
||||
|
||||
public int readUnsignedByte() throws IOException {
|
||||
return this.read();
|
||||
}
|
||||
|
||||
public short readShort() throws IOException {
|
||||
return (short)((this.read() << 8) + this.read());
|
||||
}
|
||||
|
||||
public int readUnsignedShort() throws IOException {
|
||||
return (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public char readChar() throws IOException {
|
||||
return (char)((this.read() << 8) + this.read());
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
return (this.read() << 24) + (this.read() << 16) + (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public long readLong() throws IOException {
|
||||
return ((long)this.readInt() << 32) + ((long)this.readInt() & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
public float readFloat() throws IOException {
|
||||
return Float.intBitsToFloat(this.readInt());
|
||||
}
|
||||
|
||||
public double readDouble() throws IOException {
|
||||
return Double.longBitsToDouble(this.readLong());
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String readUTF() throws IOException {
|
||||
int n = this.readUnsignedShort();
|
||||
StringBuffer stringBuffer = new StringBuffer(n);
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
int n3 = this.read();
|
||||
switch (n3 >> 4) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: {
|
||||
++n2;
|
||||
stringBuffer.append((char)n3);
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
case 13: {
|
||||
if ((n2 += 2) > n) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
int n4 = this.read();
|
||||
if ((n4 & 0xC0) != 128) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
stringBuffer.append((char)((n3 & 0x1F) << 6 | n4 & 0x3F));
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
if ((n2 += 3) > n) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
int n4 = this.read();
|
||||
int n5 = this.read();
|
||||
if ((n4 & 0xC0) != 128 || (n5 & 0xC0) != 128) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
stringBuffer.append((char)((n3 & 0xF) << 12 | (n4 & 0x3F) << 6 | n5 & 0x3F));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new String(stringBuffer);
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.pageIndex = -1;
|
||||
}
|
||||
|
||||
public PageReader(AlarmStore alarmStore) throws IOException {
|
||||
this(alarmStore, -1);
|
||||
}
|
||||
|
||||
public PageReader(AlarmStore alarmStore, int n) throws IOException {
|
||||
this.this();
|
||||
this.store = alarmStore;
|
||||
this.init(n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Random;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class SkipList {
|
||||
public static final int EQUAL_OR_AFTER = 0;
|
||||
public static final int EQUAL_OR_BEFORE = 1;
|
||||
public static final int EQUAL = 2;
|
||||
private int maxLevel;
|
||||
private IndexEntry header;
|
||||
private double probability;
|
||||
private int level;
|
||||
private int size;
|
||||
private Random rand;
|
||||
private IndexEntry[] addAt;
|
||||
private IndexEntry[] removeAt;
|
||||
private IndexEntry[] findAt;
|
||||
|
||||
public synchronized int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.getNext(this.header, 0);
|
||||
}
|
||||
|
||||
public synchronized void add(IndexEntry indexEntry) {
|
||||
int n = this.generateNewLevel();
|
||||
this.setLevel(indexEntry, n);
|
||||
if (n > this.level) {
|
||||
this.level = n;
|
||||
}
|
||||
this.pathTo(indexEntry, this.addAt);
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if (n2 == 0) {
|
||||
this.setPrev(indexEntry, this.addAt[0]);
|
||||
IndexEntry indexEntry2 = this.getNext(this.addAt[0], 0);
|
||||
if (indexEntry2 != null) {
|
||||
this.setPrev(indexEntry2, indexEntry);
|
||||
}
|
||||
}
|
||||
this.setNext(indexEntry, n2, this.getNext(this.addAt[n2], n2));
|
||||
this.setNext(this.addAt[n2], n2, indexEntry);
|
||||
++n2;
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public synchronized void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0) {
|
||||
return;
|
||||
}
|
||||
this.pathTo(indexEntry, this.removeAt);
|
||||
IndexEntry indexEntry2 = this.getNext(this.removeAt[0], 0);
|
||||
if (!indexEntry2.equals(indexEntry)) {
|
||||
throw new IllegalArgumentException("Entry not found: " + this.entryToString(indexEntry2));
|
||||
}
|
||||
int n = 0;
|
||||
while (n < this.level) {
|
||||
IndexEntry indexEntry3;
|
||||
if (this.getNext(this.removeAt[n], n) != indexEntry2) break;
|
||||
if (n == 0 && (indexEntry3 = this.getNext(indexEntry2, 0)) != null) {
|
||||
this.setPrev(indexEntry3, this.removeAt[0]);
|
||||
}
|
||||
this.setNext(this.removeAt[n], n, this.getNext(indexEntry2, n));
|
||||
++n;
|
||||
}
|
||||
while (this.level > 1 && this.getNext(this.header, this.level - 1) == null) {
|
||||
--this.level;
|
||||
}
|
||||
n = this.level;
|
||||
while (n < this.maxLevel) {
|
||||
this.addAt[n] = null;
|
||||
this.removeAt[n] = null;
|
||||
this.findAt[n] = null;
|
||||
++n;
|
||||
}
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public IndexEntry find(Object object) {
|
||||
this.pathTo(object, this.findAt);
|
||||
return this.findAt[0];
|
||||
}
|
||||
|
||||
protected void pathTo(Object object, IndexEntry[] indexEntryArray) {
|
||||
IndexEntry indexEntry = this.header;
|
||||
IndexEntry indexEntry2 = null;
|
||||
int n = this.level - 1;
|
||||
while (n >= 0) {
|
||||
indexEntry2 = this.getNext(indexEntry, n);
|
||||
while (indexEntry2 != null && this.compareToKey(indexEntry2, object) < 0) {
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getNext(indexEntry2, n);
|
||||
}
|
||||
indexEntryArray[n] = indexEntry;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
protected void pathTo(IndexEntry indexEntry, IndexEntry[] indexEntryArray) {
|
||||
IndexEntry indexEntry2 = this.header;
|
||||
IndexEntry indexEntry3 = null;
|
||||
int n = this.level - 1;
|
||||
while (n >= 0) {
|
||||
indexEntry3 = this.getNext(indexEntry2, n);
|
||||
while (indexEntry3 != null && this.isBefore(indexEntry3, indexEntry)) {
|
||||
indexEntry2 = indexEntry3;
|
||||
indexEntry3 = this.getNext(indexEntry3, n);
|
||||
}
|
||||
indexEntryArray[n] = indexEntry2;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
private final int generateNewLevel() {
|
||||
if (this.size == 0) {
|
||||
return 1;
|
||||
}
|
||||
int n = 1;
|
||||
while (this.rand.nextDouble() < this.probability && n < this.maxLevel) {
|
||||
if (++n != this.level + 1) continue;
|
||||
return n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
protected abstract int compare(IndexEntry var1, IndexEntry var2);
|
||||
|
||||
protected abstract int compareToKey(IndexEntry var1, Object var2);
|
||||
|
||||
protected boolean equals(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected boolean isBefore(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) < 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected boolean isAfter(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) > 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected abstract int getLevel(IndexEntry var1);
|
||||
|
||||
protected abstract void setLevel(IndexEntry var1, int var2);
|
||||
|
||||
protected abstract IndexEntry getNext(IndexEntry var1, int var2);
|
||||
|
||||
protected abstract void setNext(IndexEntry var1, int var2, IndexEntry var3);
|
||||
|
||||
protected abstract IndexEntry getPrev(IndexEntry var1);
|
||||
|
||||
protected abstract void setPrev(IndexEntry var1, IndexEntry var2);
|
||||
|
||||
public void dump() throws IOException {
|
||||
this.dump(null);
|
||||
}
|
||||
|
||||
public void dump(AlarmStore alarmStore) throws IOException {
|
||||
int n = 0;
|
||||
IndexEntry indexEntry = this.getNext(this.header, 0);
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
if (alarmStore != null) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
}
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ": (" + this.getLevel(indexEntry) + ") " + this.entryToString(indexEntry));
|
||||
if (alarmStore != null) {
|
||||
bAlarmRecord = alarmStore.readRecord(indexEntry.pageIndex, bAlarmRecord, null);
|
||||
System.out.println(" " + bAlarmRecord.toSummaryString());
|
||||
}
|
||||
indexEntry = this.getNext(indexEntry, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void analyze(String string, PrintStream printStream) {
|
||||
printStream.println(string);
|
||||
printStream.println(" probability: " + this.probability);
|
||||
printStream.println(" maxLevel : " + this.maxLevel);
|
||||
printStream.println(" level : " + this.level);
|
||||
int[] nArray = new int[this.level];
|
||||
int n = 0;
|
||||
while (n < this.level) {
|
||||
IndexEntry indexEntry = this.getNext(this.header, n);
|
||||
while (indexEntry != null) {
|
||||
nArray[n] = nArray[n] + 1;
|
||||
indexEntry = this.getNext(indexEntry, n);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
n = 0;
|
||||
while (n < this.level) {
|
||||
System.out.println(" level " + (n + 1) + ": " + nArray[n]);
|
||||
++n;
|
||||
}
|
||||
n = this.size * 4;
|
||||
int n2 = 0;
|
||||
while (n2 < this.level) {
|
||||
n += nArray[n2] * 4;
|
||||
++n2;
|
||||
}
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###,###,###.##");
|
||||
printStream.println(" ptr ram : " + decimalFormat.format((double)n / 1024.0 / 1024.0) + " MB");
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
int n = 0;
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.getNext(this.header, 0);
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && this.isAfter(indexEntry, indexEntry2)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + this.entryToString(indexEntry2) + " is before " + this.entryToString(indexEntry));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getNext(indexEntry2, 0);
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry2 = indexEntry;
|
||||
n = 0;
|
||||
indexEntry = null;
|
||||
while (indexEntry2 != this.header) {
|
||||
++n;
|
||||
if (indexEntry != null && this.isBefore(indexEntry, indexEntry2)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + this.entryToString(indexEntry2) + " is after " + this.entryToString(indexEntry));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getPrev(indexEntry2);
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String entryToString(IndexEntry var1);
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.rand = new Random();
|
||||
}
|
||||
|
||||
public SkipList(double d, int n) {
|
||||
this.this();
|
||||
this.maxLevel = (int)(Math.log(n) / Math.log(1.0 / d)) + 1;
|
||||
this.probability = d;
|
||||
this.header = new IndexEntry();
|
||||
this.setLevel(this.header, this.maxLevel);
|
||||
this.level = 1;
|
||||
this.size = 0;
|
||||
this.addAt = new IndexEntry[this.maxLevel];
|
||||
this.removeAt = new IndexEntry[this.maxLevel];
|
||||
this.findAt = new IndexEntry[this.maxLevel];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.SkipList;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class TimestampIndex
|
||||
extends SkipList {
|
||||
public IndexEntry find(Object object) {
|
||||
BAbsTime bAbsTime = (BAbsTime)object;
|
||||
IndexEntry indexEntry = super.find(object);
|
||||
if (indexEntry.timestamp == null) {
|
||||
return indexEntry;
|
||||
}
|
||||
if (!indexEntry.timestamp.equals((Object)bAbsTime)) {
|
||||
return indexEntry;
|
||||
}
|
||||
IndexEntry indexEntry2 = this.getPrev(indexEntry);
|
||||
while (indexEntry2.timestamp != null && indexEntry2.timestamp.equals((Object)bAbsTime)) {
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getPrev(indexEntry);
|
||||
}
|
||||
return indexEntry;
|
||||
}
|
||||
|
||||
protected int compareToKey(IndexEntry indexEntry, Object object) {
|
||||
return indexEntry.timestamp.compareTo((Object)((BAbsTime)object));
|
||||
}
|
||||
|
||||
protected int compare(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
int n = indexEntry.timestamp.compareTo((Object)indexEntry2.timestamp);
|
||||
if (n == 0) {
|
||||
return indexEntry.pageIndex - indexEntry2.pageIndex;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
protected int getLevel(IndexEntry indexEntry) {
|
||||
return indexEntry.nextTimestamp.length;
|
||||
}
|
||||
|
||||
protected void setLevel(IndexEntry indexEntry, int n) {
|
||||
indexEntry.nextTimestamp = new IndexEntry[n];
|
||||
}
|
||||
|
||||
protected IndexEntry getNext(IndexEntry indexEntry, int n) {
|
||||
return indexEntry.nextTimestamp[n];
|
||||
}
|
||||
|
||||
protected void setNext(IndexEntry indexEntry, int n, IndexEntry indexEntry2) {
|
||||
indexEntry.nextTimestamp[n] = indexEntry2;
|
||||
}
|
||||
|
||||
protected IndexEntry getPrev(IndexEntry indexEntry) {
|
||||
return indexEntry.prevTimestamp;
|
||||
}
|
||||
|
||||
protected void setPrev(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
indexEntry.prevTimestamp = indexEntry2;
|
||||
}
|
||||
|
||||
public String entryToString(IndexEntry indexEntry) {
|
||||
return indexEntry.timestamp.toString((Context)BAlarmRecord.TIMESTAMP_FACETS) + " => " + indexEntry.pageIndex;
|
||||
}
|
||||
|
||||
public TimestampIndex(double d, int n) {
|
||||
super(d, n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.memory;
|
||||
|
||||
import com.tridium.alarm.FilterCursor;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.nre.util.IFilter;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BMemoryAlarmDatabase
|
||||
extends BAlarmDatabase {
|
||||
public static final Type TYPE;
|
||||
private static final String CAPACITY = "capacity";
|
||||
private int capacity;
|
||||
private AlarmEntry first;
|
||||
private AlarmEntry last;
|
||||
private int recordCount;
|
||||
private HashMap byUuid;
|
||||
private IFilter openFilter;
|
||||
private IFilter ackPendingFilter;
|
||||
private BAlarmService alarmService;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClass;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doOpen() {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
}
|
||||
|
||||
protected void doClose() {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
Object object;
|
||||
AlarmEntry alarmEntry = new AlarmEntry((BAlarmRecord)bAlarmRecord.newCopy(true));
|
||||
if (this.first == null) {
|
||||
this.first = this.last = alarmEntry;
|
||||
} else {
|
||||
object = bAlarmRecord.getTimestamp();
|
||||
AlarmEntry alarmEntry2 = this.first;
|
||||
while (alarmEntry2 != null && alarmEntry2.rec.getTimestamp().isBefore((BAbsTime)object)) {
|
||||
alarmEntry2 = alarmEntry2.next;
|
||||
}
|
||||
if (alarmEntry2 == null) {
|
||||
this.last.next = alarmEntry;
|
||||
alarmEntry.prev = this.last;
|
||||
this.last = alarmEntry;
|
||||
} else {
|
||||
alarmEntry.prev = alarmEntry2.prev;
|
||||
if (alarmEntry2.prev != null) {
|
||||
alarmEntry2.prev.next = alarmEntry;
|
||||
}
|
||||
alarmEntry.next = alarmEntry2;
|
||||
alarmEntry2.prev = alarmEntry;
|
||||
if (alarmEntry2 == this.first) {
|
||||
this.first = alarmEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.byUuid.put(bAlarmRecord.getUuid(), alarmEntry);
|
||||
++this.recordCount;
|
||||
object = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (object.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
((BAlarmClass)((Object)object)).setTotalAlarmCount(((BAlarmClass)((Object)object)).getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
((BAlarmClass)((Object)object)).setUnackedAlarmCount(((BAlarmClass)((Object)object)).getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
((BAlarmClass)((Object)object)).setInAlarmCount(((BAlarmClass)((Object)object)).getInAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
((BAlarmClass)((Object)object)).setOpenAlarmCount(((BAlarmClass)((Object)object)).getOpenAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
if (this.recordCount > this.capacity) {
|
||||
this.trim();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
bAlarmRecord.write(new DataOutputStream(byteArrayOutputStream));
|
||||
BUuid bUuid = bAlarmRecord.getUuid();
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
if (!alarmEntry.rec.isAcknowledged() && bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
} else if (alarmEntry.rec.isAcknowledged() && !bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen() && !bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!alarmEntry.rec.isNormal() && bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
alarmEntry.rec = (BAlarmRecord)bAlarmRecord.newCopy(true);
|
||||
} else {
|
||||
this.append(bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(BAlarmRecord bAlarmRecord) {
|
||||
BUuid bUuid = bAlarmRecord.getUuid();
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
if (alarmEntry.prev != null) {
|
||||
alarmEntry.prev.next = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry.next != null) {
|
||||
alarmEntry.next.prev = alarmEntry.prev;
|
||||
}
|
||||
if (alarmEntry == this.first) {
|
||||
this.first = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry == this.last) {
|
||||
this.last = alarmEntry.prev;
|
||||
}
|
||||
alarmEntry.prev = null;
|
||||
alarmEntry.next = null;
|
||||
this.byUuid.remove(bUuid);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void trim() {
|
||||
while (this.recordCount > this.capacity) {
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = this.first.next;
|
||||
alarmEntry.next = null;
|
||||
if (this.first != null) {
|
||||
this.first.prev = null;
|
||||
}
|
||||
this.byUuid.remove(alarmEntry.rec.getUuid());
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (!bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) continue;
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isNormal()) continue;
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
return this.recordCount;
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(BUuid bUuid) {
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry == null) {
|
||||
return null;
|
||||
}
|
||||
return alarmEntry.rec;
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() throws IOException, AlarmException {
|
||||
return new AlarmCursor(this, this.first, BAbsTime.NULL, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) throws IOException, AlarmException {
|
||||
AlarmEntry alarmEntry = null;
|
||||
AlarmEntry alarmEntry2 = this.first;
|
||||
while (alarmEntry2 != null) {
|
||||
if (!alarmEntry2.rec.getTimestamp().isBefore(bAbsTime)) {
|
||||
alarmEntry = alarmEntry2;
|
||||
break;
|
||||
}
|
||||
alarmEntry2 = alarmEntry2.next;
|
||||
}
|
||||
return new AlarmCursor(this, alarmEntry, bAbsTime2, null);
|
||||
}
|
||||
|
||||
public Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
return new FilterCursor(new SourceFilter(bOrdList), this.scan());
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarms() throws IOException {
|
||||
return new FilterCursor(this.openFilter, this.scan());
|
||||
}
|
||||
|
||||
public Cursor getAckPendingAlarms() throws IOException {
|
||||
return new FilterCursor(this.ackPendingFilter, this.scan());
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmClass;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmClass = BMemoryAlarmDatabase.class("[Ljavax.baja.alarm.BAlarmClass;", false);
|
||||
}
|
||||
BAlarmClass[] bAlarmClassArray = (BAlarmClass[])this.alarmService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bAlarmClassArray.length) {
|
||||
bAlarmClassArray[n].setTotalAlarmCount(0);
|
||||
bAlarmClassArray[n].setUnackedAlarmCount(0);
|
||||
bAlarmClassArray[n].setOpenAlarmCount(0);
|
||||
bAlarmClassArray[n].setInAlarmCount(0);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
while (this.first != null) {
|
||||
if (!bAbsTime.isAfter(this.first.rec.getTimestamp())) {
|
||||
return;
|
||||
}
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = this.first.next;
|
||||
alarmEntry.next = null;
|
||||
if (this.first != null) {
|
||||
this.first.prev = null;
|
||||
}
|
||||
this.byUuid.remove(alarmEntry.rec.getUuid());
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (!bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) continue;
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isNormal()) continue;
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRecord(BUuid bUuid, Context context) {
|
||||
if (bUuid == null || bUuid.isNull()) {
|
||||
return;
|
||||
}
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
if (alarmEntry.prev != null) {
|
||||
alarmEntry.prev.next = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry.next != null) {
|
||||
alarmEntry.next.prev = alarmEntry.prev;
|
||||
}
|
||||
alarmEntry.next = null;
|
||||
alarmEntry.prev = null;
|
||||
this.byUuid.remove(bUuid);
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!alarmEntry.rec.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
if (this.byUuid.size() == 0) {
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
}
|
||||
alarmEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void setCapacity(int n) throws IOException {
|
||||
if (n < 5) {
|
||||
throw new IllegalArgumentException("Attempted to set capacity < 5.");
|
||||
}
|
||||
if (this.capacity == n) {
|
||||
return;
|
||||
}
|
||||
this.capacity = n;
|
||||
if (!this.isOpen()) {
|
||||
return;
|
||||
}
|
||||
BMemoryAlarmDatabase bMemoryAlarmDatabase = this;
|
||||
synchronized (bMemoryAlarmDatabase) {
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.recordCount = 0;
|
||||
while (alarmEntry != null) {
|
||||
this.append(alarmEntry.rec);
|
||||
alarmEntry = alarmEntry.next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.capacity = 1000;
|
||||
this.byUuid = new HashMap();
|
||||
this.openFilter = new OpenFilter();
|
||||
this.ackPendingFilter = new AckPendingFilter();
|
||||
}
|
||||
|
||||
public BMemoryAlarmDatabase() {
|
||||
this.this();
|
||||
this.alarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase = BMemoryAlarmDatabase.class("[Lcom.tridium.alarm.db.memory.BMemoryAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmEntry {
|
||||
BAlarmRecord rec;
|
||||
AlarmEntry prev;
|
||||
AlarmEntry next;
|
||||
|
||||
public AlarmEntry(BAlarmRecord bAlarmRecord) {
|
||||
this.rec = bAlarmRecord;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmCursor
|
||||
implements Cursor {
|
||||
private BMemoryAlarmDatabase db;
|
||||
private AlarmEntry start;
|
||||
private AlarmEntry entry;
|
||||
private BAbsTime endTime;
|
||||
private Context context;
|
||||
|
||||
public Context getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.start == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.entry == null) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
return this.entry.rec;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.start == null) {
|
||||
return false;
|
||||
}
|
||||
BMemoryAlarmDatabase bMemoryAlarmDatabase = this.db;
|
||||
synchronized (bMemoryAlarmDatabase) {
|
||||
this.entry = this.entry == null ? this.start : this.entry.next;
|
||||
if (this.entry == null) {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BMemoryAlarmDatabase.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
return this.next();
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public AlarmCursor(BMemoryAlarmDatabase bMemoryAlarmDatabase2, AlarmEntry alarmEntry, BAbsTime bAbsTime, Context context) {
|
||||
this.db = bMemoryAlarmDatabase2;
|
||||
this.start = alarmEntry;
|
||||
this.endTime = bAbsTime;
|
||||
this.context = context;
|
||||
this.entry = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class SourceFilter
|
||||
implements IFilter {
|
||||
BOrdList source;
|
||||
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).getSource().equals((Object)this.source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public SourceFilter(BOrdList bOrdList) {
|
||||
this.source = bOrdList;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class OpenFilter
|
||||
implements IFilter {
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).isOpen();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AckPendingFilter
|
||||
implements IFilter {
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).isAckPending();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user