Permalink
Browse files

Fix for Bug 7043: add more information to event log files

  • Loading branch information...
1 parent 4f30032 commit 925f35f80b6da9967d59ec819ac186401f0a9ee8 @timf timf committed Jun 9, 2010
@@ -22,10 +22,24 @@ public void create(int id,
String ownerDN,
long minutesRequested);
+ public void create(int id,
+ String ownerDN,
+ long minutesRequested,
+ String network,
+ String resource,
+ String clientLaunchName);
+
public void destroy(int id,
String ownerDN,
long minutesElapsed);
+ public void destroy(int id,
+ String ownerDN,
+ long minutesElapsed,
+ String network,
+ String resource,
+ String clientLaunchName);
+
// Any portion used costs this many minutes (ceiling).
// If this is for example set to 60, then 1 minute will cost 60 minutes,
// 61 minutes will cost 120, etc.
@@ -212,9 +212,30 @@ public synchronized void initialize() throws Exception {
// -------------------------------------------------------------------------
public void create(int id, String ownerDN, long minutesRequested) {
+ this.create(id, ownerDN, minutesRequested, null, null, null);
+ }
+
+ public void create(int id, String ownerDN, long minutesRequested,
+ String network, String resource, String clientLaunchName) {
+
+ String moreToLog = "";
+
+ if (resource != null) {
+ moreToLog += ", vmm='" + resource.trim() + '\'';
+ }
+
+ if (clientLaunchName != null) {
+ moreToLog += ", clientLaunchName='" + clientLaunchName.trim() + '\'';
+ }
+
+
+ if (network != null) {
+ moreToLog += ", network='" + network.trim() + '\'';
+ }
+
if (this.lager.accounting) {
logger.trace("create(): id = " + id + ", ownerDN = '" +
- ownerDN + "', minutesRequested = " + minutesRequested);
+ ownerDN + "', minutesRequested = " + minutesRequested + moreToLog);
}
if (!this.initialized) {
@@ -274,13 +295,13 @@ public void create(int id, String ownerDN, long minutesRequested) {
logger.info(Lager.ev(id) + "accounting: ownerDN = '" +
ownerDN + "', minutesRequested = " + minutesRequested +
", minutes reserved = " + charge +
- ", uuid = '" + uuid + "'");
+ ", uuid = '" + uuid + "'" + moreToLog);
}
if (this.fileLog != null) {
try {
this.fileLog.logCreate(uuid, id, ownerDN,
- minutesRequested, charge, now);
+ minutesRequested, charge, now, moreToLog);
} catch (WorkspaceException e) {
if (logger.isDebugEnabled()) {
logger.error(e.getMessage(), e);
@@ -298,9 +319,30 @@ public void create(int id, String ownerDN, long minutesRequested) {
}
public void destroy(int id, String ownerDN, long minutesElapsed) {
+ this.destroy(id, ownerDN, minutesElapsed, null, null, null);
+ }
+
+ public void destroy(int id, String ownerDN, long minutesElapsed,
+ String network, String resource, String clientLaunchName) {
+
+ String moreToLog = "";
+
+ if (resource != null) {
+ moreToLog += ", vmm='" + resource.trim() + '\'';
+ }
+
+ if (clientLaunchName != null) {
+ moreToLog += ", clientLaunchName='" + clientLaunchName.trim() + '\'';
+ }
+
+
+ if (network != null) {
+ moreToLog += ", network='" + network.trim() + '\'';
+ }
+
if (this.lager.accounting) {
logger.trace("destroy(): id = " + id + ", ownerDN = '" +
- ownerDN + "', minutesElapsed = " + minutesElapsed);
+ ownerDN + "', minutesElapsed = " + minutesElapsed + moreToLog);
}
if (!this.initialized) {
@@ -319,13 +361,13 @@ public void destroy(int id, String ownerDN, long minutesElapsed) {
logger.info(Lager.ev(id) + "accounting: ownerDN = '" +
ownerDN + "', minutesElapsed = " + charge +
", real usage = " + minutesElapsed +
- ", uuid = '" + uuid + "'");
+ ", uuid = '" + uuid + "'" + moreToLog);
}
if (this.fileLog != null) {
final Calendar now = Calendar.getInstance();
try {
- this.fileLog.logRemove(uuid, id, ownerDN, charge, now);
+ this.fileLog.logRemove(uuid, id, ownerDN, charge, now, moreToLog);
} catch (WorkspaceException e) {
if (logger.isDebugEnabled()) {
logger.error(e.getMessage(), e);
@@ -265,10 +265,11 @@ public synchronized void logCreate(String uuid,
String ownerDN,
long minutesRequested,
long charge,
- Calendar now) throws WorkspaceException {
+ Calendar now,
+ String moreToLog) throws WorkspaceException {
try {
- this.create(uuid, id, ownerDN, minutesRequested, charge, now);
+ this.create(uuid, id, ownerDN, minutesRequested, charge, now, moreToLog);
this.schedule();
} catch (Throwable t) {
logger.error(t.getMessage(), t);
@@ -281,7 +282,8 @@ private void create(String uuid,
String ownerDN,
long minutesRequested,
long charge,
- Calendar now) {
+ Calendar now,
+ String moreToLog) {
final StringBuffer buf = new StringBuffer(128);
buf.append("CREATED: time=\"")
@@ -297,17 +299,23 @@ private void create(String uuid,
.append(", charge=")
.append(charge);
+ if (moreToLog != null) {
+ buf.append(moreToLog);
+ }
+
+
this.unwrittenEvents.add(buf.toString());
}
public synchronized void logRemove(String uuid,
int id,
String ownerDN,
long charge,
- Calendar now) throws WorkspaceException {
+ Calendar now,
+ String moreToLog) throws WorkspaceException {
try {
- this.remove(uuid, id, ownerDN, charge, now);
+ this.remove(uuid, id, ownerDN, charge, now, moreToLog);
this.schedule();
} catch (Throwable t) {
logger.error(t.getMessage(), t);
@@ -319,7 +327,8 @@ private void remove(String uuid,
int id,
String ownerDN,
long charge,
- Calendar now) {
+ Calendar now,
+ String moreToLog) {
final StringBuffer buf = new StringBuffer(128);
@@ -334,6 +343,10 @@ private void remove(String uuid,
.append("\", charge=")
.append(charge);
+ if (moreToLog != null) {
+ buf.append(moreToLog);
+ }
+
this.unwrittenEvents.add(buf.toString());
}
@@ -593,7 +593,20 @@ protected CreateResult create3(Reservation res,
for (int i = 0; i < ids.length; i++) {
- this.accounting.create(ids[i], callerID, requestedMinutes);
+
+ final String resource;
+ if (res.isConcrete()) {
+ final IdHostnameTuple tup = res.getIdHostnamePair(i);
+ resource = tup.hostname;
+ } else {
+ resource = null;
+ }
+
+ final String network = bindings[i].getNetwork();
+ final String name = bindings[i].getName();
+
+ this.accounting.create(ids[i], callerID, requestedMinutes,
+ network, resource, name);
}
}
@@ -770,15 +770,30 @@ protected void do_remove() {
"no stop event generated");
}
} else {
+
+ final String network;
+ final String resource;
+ if (this.vm != null) {
+ network = this.vm.getNetwork();
+ resource = this.vm.getNode();
+ } else {
+ network = null;
+ resource = null;
+ }
+
if (this.startTime == null) {
if (lager.accounting) {
logger.debug("no start time available (will happen with " +
"best effort scheduler with destruction coming " +
"before any resource assignment");
}
+
this.accounting.destroy(this.id,
this.getCreatorID(),
- 0L);
+ 0L,
+ network,
+ resource,
+ this.name);
} else {
final long runningTimeMS =
Calendar.getInstance().getTimeInMillis() -
@@ -792,7 +807,10 @@ protected void do_remove() {
this.accounting.destroy(this.id,
this.getCreatorID(),
- runningTime);
+ runningTime,
+ network,
+ resource,
+ this.name);
}
}

0 comments on commit 925f35f

Please sign in to comment.