[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3124 - in freeway: . native src/org/gnu/freeway/protocol/s
From: |
mdonoughe |
Subject: |
[GNUnet-SVN] r3124 - in freeway: . native src/org/gnu/freeway/protocol/stats src/org/gnu/freeway/services/java src/org/gnu/freeway/util/net |
Date: |
Tue, 18 Jul 2006 17:36:55 -0700 (PDT) |
Author: mdonoughe
Date: 2006-07-18 17:36:44 -0700 (Tue, 18 Jul 2006)
New Revision: 3124
Added:
freeway/src/org/gnu/freeway/protocol/stats/CSStatsMessage.java
Modified:
freeway/
freeway/native/org_gnu_freeway_server_CPluginLoader.c
freeway/native/switch-table.c
freeway/src/org/gnu/freeway/protocol/stats/StatsProtocol.java
freeway/src/org/gnu/freeway/services/java/StatsService.java
freeway/src/org/gnu/freeway/util/net/PersistentHelper.java
Log:
fixed bug where C services wouldn't work after their protocols finished
initializing
made the statistics service use milliseconds because that is what gnunet-stats
expects
Property changes on: freeway
___________________________________________________________________
Name: svk:merge
- ca0d4bff-9018-0410-8ce9-c5d843b21c37:/local/freeway:64
+ ca0d4bff-9018-0410-8ce9-c5d843b21c37:/local/freeway:66
Modified: freeway/native/org_gnu_freeway_server_CPluginLoader.c
===================================================================
--- freeway/native/org_gnu_freeway_server_CPluginLoader.c 2006-07-17
19:33:09 UTC (rev 3123)
+++ freeway/native/org_gnu_freeway_server_CPluginLoader.c 2006-07-19
00:36:44 UTC (rev 3124)
@@ -885,7 +885,6 @@
goto ULE;
}
ok = mptr(&jcapi);
- m->moduleFptrStruct = NULL;
if (ok == SYSERR) {
MUTEX_UNLOCK(&m->mutex);
releaseModule(m);
Modified: freeway/native/switch-table.c
===================================================================
--- freeway/native/switch-table.c 2006-07-17 19:33:09 UTC (rev 3123)
+++ freeway/native/switch-table.c 2006-07-19 00:36:44 UTC (rev 3124)
@@ -11,7 +11,6 @@
switch (functionType) {
case 13: {
PointerObject * carg0 = convObjectToPtr(jargs[0], env);
-fprintf(stderr, "13: %x %d %x\n", m->modulePtr, functionOffset, carg0);
int cret = ((FunctionType13)
((void**)m->moduleFptrStruct)[functionOffset])(carg0->pointer);
updateObjectFromPtr(jargs[0], carg0, env);
oret = convIntToCInt(cret, env);
@@ -20,21 +19,17 @@
case 60: {
int carg0 = convCIntToInt(jargs[0], env);
long long carg1 = convCLongToLong(jargs[1], env);
-fprintf(stderr, "60: %x %d %d %l\n", m->modulePtr, functionOffset, carg0,
carg1);
((FunctionType60) ((void**)m->moduleFptrStruct)[functionOffset])(carg0,
carg1);
break;
}
case 42: {
int carg0 = convCIntToInt(jargs[0], env);
int carg1 = convCIntToInt(jargs[1], env);
-fprintf(stderr, "42: %x %d %d %d\n", m->modulePtr, functionOffset, carg0,
carg1);
((FunctionType42) ((void**)m->moduleFptrStruct)[functionOffset])(carg0,
carg1);
break;
}
case 10: {
int carg0 = convCIntToInt(jargs[0], env);
-//Please check this out
-fprintf(stderr, "This is important for some reason: %x %d %x\n", m->modulePtr,
functionOffset, carg0);
long long cret = ((FunctionType10)
((void**)m->moduleFptrStruct)[functionOffset])(carg0);
oret = convLongToCLong(cret, env);
break;
Added: freeway/src/org/gnu/freeway/protocol/stats/CSStatsMessage.java
===================================================================
--- freeway/src/org/gnu/freeway/protocol/stats/CSStatsMessage.java
2006-07-17 19:33:09 UTC (rev 3123)
+++ freeway/src/org/gnu/freeway/protocol/stats/CSStatsMessage.java
2006-07-19 00:36:44 UTC (rev 3124)
@@ -0,0 +1,183 @@
+ /*
+ This file is part of Freeway
+
+ Freeway is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ Freeway is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Freeway; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+package org.gnu.freeway.protocol.stats;
+
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.gnu.freeway.cwrappers.CLong;
+import org.gnu.freeway.cwrappers.ConstCLong;
+import org.gnu.freeway.services.java.StatsService;
+import org.gnu.freeway.util.Scheduler;
+import org.gnu.freeway.util.net.CSMessage;
+import org.gnu.freeway.util.net.ErrorReporter;
+import org.gnu.freeway.util.net.Persistent;
+
+/**
+ * @file CSStatsMessage.java
+ * @brief
+ * @author mdonoughe
+ */
+
+public class CSStatsMessage extends CSMessage implements Persistent {
+ private StatsService src;
+ private int size;
+ private long startTime;
+ private int totalCounters;
+ private List stats;
+ private static final int SIZE = 24;
+
+ public CSStatsMessage() {
+ super(CS_PROTO_stats_STATISTICS);
+ size = SIZE;
+ startTime=Scheduler.toMillis(Scheduler.now());
+ totalCounters = 0;
+ stats = new ArrayList();
+ }
+
+ public CSStatsMessage(long time) {
+ this();
+ this.startTime = time;
+ }
+
+ public String toString() {
+ return "Statistics message [counters=" + stats.size() + ",
totalCounters=" + totalCounters + "]";
+ }
+
+ public long getStartTime()
+ {
+ return Scheduler.toSeconds(startTime);
+ }
+
+ public int getTotalCounters()
+ {
+ return totalCounters;
+ }
+
+ public void setTotalCounters( int total )
+ {
+ totalCounters=total;
+ }
+
+ public void add(StatsService.Entry stat) {
+ stats.add(stat);
+ size += stat.getByteSize();
+ }
+
+ public StatsService.Entry removeLast()
+ {
+ StatsService.Entry stat;
+
+ assert(stats.size()>0);
+
+ stat=(StatsService.Entry) stats.remove(stats.size()-1);
+ size-=stat.getByteSize();
+ return stat;
+ }
+
+ public StatsService.Entry[] getStatistics()
+ {
+ return (StatsService.Entry[]) stats.toArray(new
StatsService.Entry[stats.size()]);
+ }
+
+ public int getByteSize()
+ {
+ return size;
+ }
+
+ public void readBytes( ByteBuffer buf, ErrorReporter err )
+ {
+ StatsService.Entry stat;
+ int type,i,n,reserved,statCounters;
+
+ size=buf.getShort() & 0x0000ffff;
+ err.reportIf(size<16,"packet too small");
+
+ type=buf.getShort() & 0x0000ffff;
+ err.reportIf(type != CS_PROTO_stats_STATISTICS, "wrong packet
type");
+
+ reserved=buf.getInt();
+ err.reportIf(reserved!=0,"'reserved' integer not null !");
+
+ startTime=buf.getLong();
+ err.reportIf(startTime<=0,"Invalid start time !");
+
+ totalCounters=buf.getInt();
+ err.reportIf(totalCounters<0,"Invalid total counter !");
+
+ statCounters=buf.getInt();
+ err.reportIf(statCounters<0,"Negative numbers of counters");
+
+ n=SIZE;
+ stats.clear();
+
+ ArrayList values = new ArrayList();
+ for (i=0; i<statCounters; i++) {
+ long l = buf.getLong();
+ values.add(new CLong(l));
+ n+=8;
+ }
+
+ for(i = 0; i<statCounters; i++) {
+ int pos=buf.position();
+ int len = 0;
+ for (len=0; buf.get()!=0; len++) {}
+ buf.position(pos);
+ byte[] b=new byte[len];
+ buf.get(b);
+ buf.get(); //null
+ try {
+ stats.add(new StatsService.Entry(new String(b,
"UTF-8"), (ConstCLong) values.get(i)));
+ } catch (UnsupportedEncodingException e) {
+ throw new Error(e);
+ }
+ n+=len+1;
+ }
+
+ err.reportIf(size!=n,"Bad size: "+size+"!="+n);
+ }
+
+ public void writeBytes( ByteBuffer buf )
+ {
+ int i;
+
+ buf.putShort((short) size);
+ buf.putShort((short) CS_PROTO_stats_STATISTICS);
+ buf.putInt(0);
+ buf.putLong(startTime);
+ buf.putInt(totalCounters);
+ buf.putInt(stats.size());
+
+ for(i = 0; i < stats.size(); i++) {
+ buf.putLong(((StatsService.Entry)
stats.get(i)).value.getValue());
+ }
+
+ for(i = 0; i < stats.size(); i++) {
+ try {
+ buf.put(((StatsService.Entry)
stats.get(i)).key.getBytes("UTF-8"));
+ } catch(Exception e) {
+ throw new Error(e);
+ }
+ buf.put((byte) 0);
+ }
+ }
+}
Modified: freeway/src/org/gnu/freeway/protocol/stats/StatsProtocol.java
===================================================================
--- freeway/src/org/gnu/freeway/protocol/stats/StatsProtocol.java
2006-07-17 19:33:09 UTC (rev 3123)
+++ freeway/src/org/gnu/freeway/protocol/stats/StatsProtocol.java
2006-07-19 00:36:44 UTC (rev 3124)
@@ -109,8 +109,6 @@
}
public boolean handle(CSSession session, CSMessage message) {
-
- System.err.println("+++" + message.getType());
if(message.getType() ==
CSMessage.CS_PROTO_stats_GET_STATISTICS) {
return handleGetStatistics(session, message);
} else if(message.getType() ==
CSMessage.CS_PROTO_stats_STATISTICS) {
@@ -142,7 +140,6 @@
private boolean handleGetStatistics(CSSession session, CSMessage
message) {
//assume that the server is telling the truth and just send a
reply
- System.err.println("!! Will send statistics to " +
session.getLabel());
sendStatistics(session);
return true;
}
@@ -159,7 +156,7 @@
i=0;
while (i < stats.size()) {
- msg=new
CSStatsMessage(Scheduler.toSeconds(service.startTime));
+ msg=new CSStatsMessage(service.startTime);
msg.setTotalCounters(total);
// how many statistic numbers and their descriptions we
can send in one message ?
@@ -180,153 +177,4 @@
System.err.println(msg.toString() + msg.getByteSize());
}
}
-
- public static final class CSStatsMessage extends CSMessage implements
Persistent {
- private StatsService src;
- private int size;
- private long startTime;
- private int totalCounters;
- private List stats;
- private static final int SIZE = 24;
-
- public CSStatsMessage() {
- super(CS_PROTO_stats_STATISTICS);
- size = SIZE;
- startTime=Scheduler.toSeconds(Scheduler.now());
- totalCounters = 0;
- stats = new ArrayList();
- }
-
- public CSStatsMessage(long time) {
- this();
- this.startTime = time;
- }
-
- public String toString() {
- return "Statistics message [counters=" + stats.size() +
", totalCounters=" + totalCounters + "]";
- }
-
- public long getStartTime()
- {
- return startTime;
- }
-
- public int getTotalCounters()
- {
- return totalCounters;
- }
-
- public void setTotalCounters( int total )
- {
- totalCounters=total;
- }
-
- public void add(StatsService.Entry stat) {
- stats.add(stat);
- size += stat.getByteSize();
- }
-
- public StatsService.Entry removeLast()
- {
- StatsService.Entry stat;
-
- assert(stats.size()>0);
-
- stat=(StatsService.Entry) stats.remove(stats.size()-1);
- size-=stat.getByteSize();
- return stat;
- }
-
- public StatsService.Entry[] getStatistics()
- {
- return (StatsService.Entry[]) stats.toArray(new
StatsService.Entry[stats.size()]);
- }
-
- public int getByteSize()
- {
- return size;
- }
-
- public void readBytes( ByteBuffer buf, ErrorReporter err )
- {
- StatsService.Entry stat;
- int type,i,n,reserved,statCounters;
-
- size=buf.getShort() & 0x0000ffff;
- err.reportIf(size<16,"packet too small");
-
- type=buf.getShort() & 0x0000ffff;
- err.reportIf(type != CS_PROTO_stats_STATISTICS, "wrong
packet type");
-
- reserved=buf.getInt();
- err.reportIf(reserved!=0,"'reserved' integer not null
!");
-
- startTime=buf.getLong();
- err.reportIf(startTime<=0,"Invalid start time !");
-
- totalCounters=buf.getInt();
- err.reportIf(totalCounters<0,"Invalid total counter !");
-
- statCounters=buf.getInt();
- err.reportIf(statCounters<0,"Negative numbers of
counters");
-
- n=SIZE;
- stats.clear();
-
- ArrayList values = new ArrayList();
- for (i=0; i<statCounters; i++) {
- long l = buf.getLong();
- values.add(new CLong(l));
- System.err.println("value: " + l);
- n+=8;
- }
-
- for(i = 0; i<statCounters; i++) {
- int pos=buf.position();
- int len = 0;
- for (len=0; buf.get()!=0; len++) {}
- buf.position(pos);
- byte[] b=new byte[len];
- buf.get(b);
- buf.get(); //null
- try {
- stats.add(new StatsService.Entry(new
String(b, "UTF-8"), (ConstCLong) values.get(i)));
- System.err.println("key: " + new
String(b, "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new Error(e);
- }
- n+=len+1;
- }
-
- err.reportIf(size!=n,"Bad size: "+size+"!="+n);
- }
-
- public void writeBytes( ByteBuffer buf )
- {
- int i;
-
- buf.putShort((short) size);
- buf.putShort((short) CS_PROTO_stats_STATISTICS);
- buf.putInt(0);
- buf.putLong(startTime);
- buf.putInt(totalCounters);
- buf.putInt(stats.size());
-
- for(i = 0; i < stats.size(); i++) {
- buf.putLong(((StatsService.Entry)
stats.get(i)).value.getValue());
- System.err.println("value: " +
((StatsService.Entry)stats.get(i)).value.getValue());
- }
-
- for(i = 0; i < stats.size(); i++) {
- try {
- buf.put(((StatsService.Entry)
stats.get(i)).key.getBytes("UTF-8"));
- } catch(Exception e) {
- throw new Error(e);
- }
- buf.put((byte) 0);
- System.err.println("key: " +
((StatsService.Entry) stats.get(i)).key);
- }
- System.err.println("wrote to buffer");
- }
- }
}
Modified: freeway/src/org/gnu/freeway/services/java/StatsService.java
===================================================================
--- freeway/src/org/gnu/freeway/services/java/StatsService.java 2006-07-17
19:33:09 UTC (rev 3123)
+++ freeway/src/org/gnu/freeway/services/java/StatsService.java 2006-07-19
00:36:44 UTC (rev 3124)
@@ -19,7 +19,7 @@
// can only be used by classes that depend on java.StatsService
public ArrayList stats;
- public int startTime;
+ public long startTime;
public synchronized CInt create(ConstCString name) {
stats.add(new Entry(name.getValue(), new ConstCLong(0)));
@@ -41,7 +41,7 @@
public void init() throws ServiceException {
super.init();
stats = new ArrayList();
- startTime = (int) Scheduler.toSeconds(Scheduler.now());
+ startTime = Scheduler.toMillis(Scheduler.now());
try {
System.err.println("Loaded Java stats service.");
Modified: freeway/src/org/gnu/freeway/util/net/PersistentHelper.java
===================================================================
--- freeway/src/org/gnu/freeway/util/net/PersistentHelper.java 2006-07-17
19:33:09 UTC (rev 3123)
+++ freeway/src/org/gnu/freeway/util/net/PersistentHelper.java 2006-07-19
00:36:44 UTC (rev 3124)
@@ -25,49 +25,38 @@
{
Persistent p;
int pos;
-System.err.println("read0 ");
p=null;
if (Persistent.class.isAssignableFrom(c)) {
- System.err.println("read1 " + p);
pos=buf.position();
try {
- System.err.println("read2 " +
c.getCanonicalName());
p=(Persistent) c.newInstance();
- System.err.println("read3 " + p);
p.readBytes(buf,new ErrorReporter());
- System.err.println("read4 " + p);
if (buf.position()!=pos+p.getByteSize()) {
- System.err.println("read5 " +
p);logger.log(Level.SEVERE,"Advertised size does not match reality
("+c.getName()+") !");
+ logger.log(Level.SEVERE,"Advertised
size does not match reality ("+c.getName()+") !");
buf.position(pos);
p=null;
}
}
catch( BufferUnderflowException x ) {
- System.err.println("read6 " + p);
logger.log(Level.SEVERE,"Buffer underflow
("+c.getName()+") !",x);
buf.position(pos);
p=null;
}
catch( IllegalStateException x ) {
- System.err.println("read7 " + p);
logger.log(Level.SEVERE,"Corrupted data
("+x.getMessage()+") !",x);
buf.position(pos);
p=null;
}
catch( InstantiationException x ) {
- System.err.println("read8 " + p);
logger.log(Level.SEVERE,"Could not create
instance of "+c.getName()+".",x);
}
catch( IllegalAccessException x ) {
- System.err.println("read9 " + p);
logger.log(Level.SEVERE,"Could not create
instance of "+c.getName()+".",x);
}
}
else {
- System.err.println("reada " + p);
logger.log(Level.SEVERE,"Instances of "+c.getName()+"
are not persistent.");
}
- System.err.println("readb " + p);
return p;
}
@@ -75,7 +64,6 @@
{
Persistent p;
p=read(c,buf);
- System.err.println("FATAL1 " + p);
if (p!=null && buf.remaining()>0) {
logger.log(Level.SEVERE,"Buffer larger than expected
("+c.getName()+").");
p=null;
@@ -133,7 +121,6 @@
if (writeFully(p,buf)) {
buf.flip();
p=readFully(p.getClass(),buf);
- System.err.println("FATAL " + p);
}
else {
p=null;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3124 - in freeway: . native src/org/gnu/freeway/protocol/stats src/org/gnu/freeway/services/java src/org/gnu/freeway/util/net,
mdonoughe <=