gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r21108 - in gnunet-java/src/org/gnunet: dht statistics util


From: gnunet
Subject: [GNUnet-SVN] r21108 - in gnunet-java/src/org/gnunet: dht statistics util
Date: Mon, 23 Apr 2012 11:47:59 +0200

Author: dold
Date: 2012-04-23 11:47:58 +0200 (Mon, 23 Apr 2012)
New Revision: 21108

Modified:
   gnunet-java/src/org/gnunet/dht/DistributedHashTable.java
   gnunet-java/src/org/gnunet/statistics/Statistics.java
   gnunet-java/src/org/gnunet/util/Configuration.java
Log:
fix


Modified: gnunet-java/src/org/gnunet/dht/DistributedHashTable.java
===================================================================
--- gnunet-java/src/org/gnunet/dht/DistributedHashTable.java    2012-04-23 
08:59:27 UTC (rev 21107)
+++ gnunet-java/src/org/gnunet/dht/DistributedHashTable.java    2012-04-23 
09:47:58 UTC (rev 21108)
@@ -12,7 +12,6 @@
 import java.util.List;
 import java.util.Set;
 
-
 /**
  * API for the gnunet dht service.
  * <p/>
@@ -197,7 +196,7 @@
     /**
      * Message to request monitoring messages, clients --> DHT service.
      */
-    @UnionCase(0)
+    @UnionCase(153)
     public static class DHTMonitorStartMessage implements GnunetMessage.Body {
         /**
          * The type of data desired, GNUNET_BLOCK_TYPE_ANY for all.
@@ -239,7 +238,7 @@
     /**
      * Message to monitor put requests going through peer, DHT service --> 
clients.
      */
-    @UnionCase(0)
+    @UnionCase(151)
     public static class DHTMonitorPutMessage implements GnunetMessage.Body {
         /**
          * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
@@ -295,6 +294,7 @@
     /**
      * Message to monitor get requests going through peer, DHT service -> 
clients.
      */
+    @UnionCase(149)
     public class DHTMonitorGetMessage implements GnunetMessage.Body {
         /**
          * Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
@@ -340,10 +340,48 @@
     /**
      * Message to monitor get results going through peer, DHT service --> 
clients.
      */
+    @UnionCase(150)
+    public class MonitorGetRespMessage implements GnunetMessage.Body {
+        /**
+         * Content type.
+         */
+        @UInt32
+        int type;
 
+        /**
+         * Length of the PUT path that follows (if tracked).
+         */
+        @UInt32
+        int put_path_length;
 
+        /**
+         * Length of the GET path that follows (if tracked).
+         */
+        @UInt32
+        int get_path_length;
 
+        /**
+         * When does the content expire?
+         */
+        @NestedMessage
+        public AbsoluteTimeMessage expiration;
 
+        /**
+         * The key of the corresponding GET request.
+         */
+        @NestedMessage
+        public HashCode key;
+
+        @VariableSizeArray(lengthField = "put_path_length")
+        public PeerIdentity[] putPath;
+
+        @VariableSizeArray(lengthField = "get_path_length")
+        public PeerIdentity[] getPath;
+
+        @ByteFill
+        public byte[] data;
+    }
+
     /**
      * Callback object for requests to the dht
      */
@@ -352,11 +390,11 @@
          * Called when the dht returns a result
          *
          * @param expiration expiration of the returned entry
-         * @param key key of the returned entry
-         * @param getPath put path of the returned entry
-         * @param putPath put path of the returned entry
-         * @param type type of data in the entry
-         * @param data data of the returned entry
+         * @param key        key of the returned entry
+         * @param getPath    put path of the returned entry
+         * @param putPath    put path of the returned entry
+         * @param type       type of data in the entry
+         * @param data       data of the returned entry
          */
         public void handleResult(AbsoluteTime expiration, HashCode key,
                                  List<PeerIdentity> getPath, 
List<PeerIdentity> putPath,
@@ -389,12 +427,12 @@
      *
      * @param key              key key to store the data under
      * @param data             data data to store
-     * @param replicationLevel  how many peers should store this value
-     * @param routeOptions  additional options
-     * @param type  type of the data to store
-     * @param expiration how long should the value be stored? TODO: what is 
the maximum?
-     * @param timeout   how long after we give up on storing the value?
-     * @param cont  called after the put operation failed or succeeded
+     * @param replicationLevel how many peers should store this value
+     * @param routeOptions     additional options
+     * @param type             type of the data to store
+     * @param expiration       how long should the value be stored? TODO: what 
is the maximum?
+     * @param timeout          how long after we give up on storing the value?
+     * @param cont             called after the put operation failed or 
succeeded
      */
     public void put(HashCode key, byte[] data, int replicationLevel, 
Set<RouteOption> routeOptions,
                     BlockType type, AbsoluteTime expiration,
@@ -408,18 +446,18 @@
 
         client.notifyTransmitReady(timeout, true,
                 0, new MessageTransmitter() {
-                    @Override
-                    public void transmit(Connection.MessageSink sink) {
-                        sink.send(cpm);
-                        // is there no way to get an ack from the dht service?
-                        cont.onSuccess();
-                    }
+            @Override
+            public void transmit(Connection.MessageSink sink) {
+                sink.send(cpm);
+                // is there no way to get an ack from the dht service?
+                cont.onSuccess();
+            }
 
-                    @Override
-                    public void handleError() {
-                        cont.onError();
-                    }
-                });
+            @Override
+            public void handleError() {
+                cont.onError();
+            }
+        });
     }
 
 
@@ -504,13 +542,13 @@
     /**
      * Request results from the DHT.
      *
-     * @param timeout timeout for the request
-     * @param type  which type of data do we want to query for? (the DHT does 
not support TYPE_ANY)
-     * @param key   the key we want to query
-     * @param replication   how many peers do we want to ask?
-     * @param routeOptions  extra routing options, null for default
-     * @param xquery    extra query parameters, defaults to null
-     * @param cb the callback object for results or failure indication
+     * @param timeout      timeout for the request
+     * @param type         which type of data do we want to query for? (the 
DHT does not support TYPE_ANY)
+     * @param key          the key we want to query
+     * @param replication  how many peers do we want to ask?
+     * @param routeOptions extra routing options, null for default
+     * @param xquery       extra query parameters, defaults to null
+     * @param cb           the callback object for results or failure 
indication
      * @return a handle to cancel the request
      */
     public Cancelable startGet(RelativeTime timeout, BlockType type, HashCode 
key,
@@ -568,9 +606,25 @@
         return request;
     }
 
+    public Cancelable monitorStart(int blockType, HashCode key, 
MonitorGetHandler getHandler,
+                                   MonitorGetResponseHandler 
getResponseHandler,
+                                   MonitorPutHandler putHandler) {
+        /*
+        MonitorHandle monitorHandle = new MonitorHandle();
+        monitorHandle.blockType = blockType;
+        monitorHandle.key = key;
+        monitorHandle.getHandler = getHandler;
+        monitorHandle.getResponseHandler = getResponseHandler;
+        monitorHandle.putHandler = putHandler;
+        */
+        return null;
 
+    }
+
+
     /**
      * not yet implemented
+     *
      * @return a handle to cancel the monitoring
      */
     public Cancelable startMonitor() {
@@ -673,4 +727,12 @@
             }
         }.start();
     }
+
+    private class MonitorHandle {}
+
+    private class MonitorGetHandler {}
+
+    private class MonitorGetResponseHandler {}
+
+    private class MonitorPutHandler {}
 }

Modified: gnunet-java/src/org/gnunet/statistics/Statistics.java
===================================================================
--- gnunet-java/src/org/gnunet/statistics/Statistics.java       2012-04-23 
08:59:27 UTC (rev 21107)
+++ gnunet-java/src/org/gnunet/statistics/Statistics.java       2012-04-23 
09:47:58 UTC (rev 21108)
@@ -22,14 +22,34 @@
 /**
  * API for the gnunet statistics service.
  * <p/>
- * Write and read statistic values, represented as 64bit integer.
+ * Write and read statistics values, represented as unsigned 64bit integer.
  */
 public class Statistics {
     private static final Logger logger = LoggerFactory
             .getLogger(Statistics.class);
 
-    private static final RelativeTime PUT_TIMEOUT = 
RelativeTime.SECOND.multiply(5);
+    /**
+     * Time after we give up setting values in statistics
+     */
+    private static final RelativeTime SET_TIMEOUT = 
RelativeTime.SECOND.multiply(5);
 
+
+    private interface Request {
+        boolean dropOnShutdown();
+        AbsoluteTime getDeadline();
+    }
+
+    /**
+     * a generic implementation of a request queue
+     */
+    private class RequestQueue<R extends Request> {
+        public Cancelable addRequest(R request) {
+            return null;
+        }
+
+    }
+
+
     private Client client;
     private LinkedList<StatisticsRequest> requests = new 
LinkedList<StatisticsRequest>();
     private Cancelable currentTransmit;
@@ -82,9 +102,6 @@
     }
 
 
-
-
-
     private class StatisticsGetRequest extends StatisticsRequest implements 
Cancelable {
         public StatisticsReceiver receiver;
         public Cancelable receiveHandle;
@@ -238,7 +255,7 @@
      */
     public Cancelable set(final String subsystem, final String name, final 
long value, boolean persist) {
         StatisticsPutRequest putRequest = new StatisticsPutRequest();
-        putRequest.deadline = PUT_TIMEOUT.toAbsolute();
+        putRequest.deadline = SET_TIMEOUT.toAbsolute();
         putRequest.subsystem = subsystem;
         putRequest.name = name;
         putRequest.value = value;

Modified: gnunet-java/src/org/gnunet/util/Configuration.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Configuration.java  2012-04-23 08:59:27 UTC 
(rev 21107)
+++ gnunet-java/src/org/gnunet/util/Configuration.java  2012-04-23 09:47:58 UTC 
(rev 21108)
@@ -358,7 +358,7 @@
         dirs.add(new File("/usr/local/share/gnunet/config.d/"));
         String pfx = System.getenv("GNUNET_PREFIX");
         if (pfx != null) {
-            dirs.add(new File(pfx, "share/config.d/"));
+            dirs.add(new File(pfx, "share/gnunet/config.d/"));
             dirs.add(new File(pfx, "config.d/"));
             dirs.add(new File(pfx, "gnunet/config.d/"));
         }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]