[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17894 - in gnunet-java: . org org/gnunet org/gnunet/servic
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17894 - in gnunet-java: . org org/gnunet org/gnunet/service org/gnunet/util org/gnunet/util/connection org/gnunet/util/time |
Date: |
Tue, 1 Nov 2011 19:30:36 +0100 |
Author: dold
Date: 2011-11-01 19:30:36 +0100 (Tue, 01 Nov 2011)
New Revision: 17894
Added:
gnunet-java/org/
gnunet-java/org/gnunet/
gnunet-java/org/gnunet/service/
gnunet-java/org/gnunet/service/StatisticsService.java
gnunet-java/org/gnunet/util/
gnunet-java/org/gnunet/util/connection/
gnunet-java/org/gnunet/util/connection/Connection.java
gnunet-java/org/gnunet/util/connection/Receiver.java
gnunet-java/org/gnunet/util/connection/TransmitReadyNotify.java
gnunet-java/org/gnunet/util/time/
gnunet-java/org/gnunet/util/time/AbsoluteTime.java
gnunet-java/org/gnunet/util/time/RelativeTime.java
Log:
initial commit of gnunet-java
Added: gnunet-java/org/gnunet/service/StatisticsService.java
===================================================================
--- gnunet-java/org/gnunet/service/StatisticsService.java
(rev 0)
+++ gnunet-java/org/gnunet/service/StatisticsService.java 2011-11-01
18:30:36 UTC (rev 17894)
@@ -0,0 +1,128 @@
+
+
+
+package org.gnunet.service;
+
+import java.util.LinkedList;
+
+import org.gnunet.util.client.Client;
+import org.gnunet.util.config.Configuration;
+import org.gnunet.util.time.AbsoluteTime;
+import org.gnunet.util.time.RelativeTime;
+
+public class StatisticsService {
+
+ interface Iterator {
+ public int call(String subsystem, String name, int value,
boolean is_persistent);
+ }
+
+ interface Callback {
+
+ }
+
+ enum ActionType {GET,SET,WATCH,UPDATE};
+
+ class GetHandle {
+ private StatisticsService sh;
+ private String subsystem;
+ private String name;
+ private Callback cont;
+ private Iterator proc;
+ private AbsoluteTime timeout;
+ private ActionType type;
+ private int msize;
+ void cancel() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private class WatchEntry {
+ String subssytem;
+ String name;
+ Iterator proc;
+ public WatchEntry(String subssytem, String name, Iterator proc)
{
+ this.subssytem = subssytem;
+ this.name = name;
+ this.proc = proc;
+ }
+ }
+
+
+
+ private Client client;
+ private RelativeTime backoff;
+
+ private String subsystem;
+ private Configuration cfg;
+
+ LinkedList<WatchEntry> watches;
+
+ LinkedList<GetHandle> actions;
+
+ GetHandle currentAction;
+
+ Client.TransmitHandle th;
+
+
+ public StatisticsService(String subsystem, Configuration cfg) {
+ this.backoff = new RelativeTime(1);
+ this.subsystem = subsystem;
+ this.cfg = cfg;
+ this.client = new Client("statistics", cfg);
+ this.watches = new LinkedList<StatisticsService.WatchEntry>();
+ this.actions = new LinkedList<StatisticsService.GetHandle>();
+ }
+
+
+ public void watch(String subsystem, String name, Iterator cb) {
+ throw new UnsupportedOperationException();
+ /*
+ WatchEntry w = new WatchEntry(subsystem, name, cb);
+ this.watches.add(w);
+ scheduleWatchRequest(w);
+ */
+ }
+
+
+
+
+ public GetHandle get(String subsystem, String name, RelativeTime
timeout,
+ Callback cb, Iterator it) {
+ GetHandle h = new GetHandle();
+ h.sh = this;
+ h.subsystem = subsystem;
+ h.name = name;
+ h.cont = cb;
+ h.proc = it;
+ h.type = ActionType.GET;
+ insertGetHandle(h);
+ return h;
+ }
+
+ private void insertGetHandle(GetHandle h) {
+ actions.add(h);
+ if (h == actions.getFirst()) {
+ scheduleAction();
+ }
+ }
+
+ private void scheduleAction() {
+ if (currentAction != null) {
+ return;
+ }
+ // XXX: What about reconnect stuff?
+ currentAction = actions.removeFirst();
+ // XXX: what about destruction?
+ this.th = client.notifyTransmitReady(currentAction.msize,
/*XXX:dummy*/ null, true, new StatisticsTransmitAction());
+
+ // XXX totally incomplete
+ }
+
+ public void set(String name, int value, boolean make_persistent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void update(String name, int delta, boolean make_persistent) {
+ throw new UnsupportedOperationException();
+ }
+}
Added: gnunet-java/org/gnunet/util/connection/Connection.java
===================================================================
--- gnunet-java/org/gnunet/util/connection/Connection.java
(rev 0)
+++ gnunet-java/org/gnunet/util/connection/Connection.java 2011-11-01
18:30:36 UTC (rev 17894)
@@ -0,0 +1,75 @@
+package org.gnunet.util.connection;
+
+import java.net.*;
+
+import org.gnunet.util.time.RelativeTime;
+
+public class Connection {
+ public class TransmitHandle {
+ void cancel() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private boolean persist;
+
+ private Connection(Socket s) {
+ }
+
+ public static Connection fromAccept(ServerSocket ss) {
+ throw new UnsupportedOperationException();
+ }
+
+ public static Connection fromExisting(Socket ss) {
+ return new Connection(ss);
+ }
+
+ public static Connection fromConnect(String hostname, long port) {
+ throw new UnsupportedOperationException();
+ }
+
+ public static Connection fromUnixPath(String path) {
+ // problematic as java has no nativ support for unix domain
sockets
+ throw new UnsupportedOperationException();
+ }
+
+ public static Connection fromSocketAddress(SocketAddress addr) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void receive(int max, RelativeTime timeout, Receiver r) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void receive_cancel() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public TransmitHandle notifyTransmitReady(int size, RelativeTime
timeout, boolean auto_retry,
+ TransmitReadyNotify cb) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void persist() {
+ this.persist = true;
+ }
+
+ // XXX: error code / exception
+ public void disableCorking() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean check() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void ignoreShutdown(boolean doIgnore) {
+
+ }
+
+ /*
+ * not implemented: GNUNET_CONNECTION_get_address (never used outside
testing)
+ */
+
+}
Added: gnunet-java/org/gnunet/util/connection/Receiver.java
===================================================================
--- gnunet-java/org/gnunet/util/connection/Receiver.java
(rev 0)
+++ gnunet-java/org/gnunet/util/connection/Receiver.java 2011-11-01
18:30:36 UTC (rev 17894)
@@ -0,0 +1,6 @@
+package org.gnunet.util.connection;
+
+public interface Receiver {
+ public void receive(byte[] buf, long available, Object sockaddr, int
addrlen, int errCode);
+
+}
Added: gnunet-java/org/gnunet/util/connection/TransmitReadyNotify.java
===================================================================
--- gnunet-java/org/gnunet/util/connection/TransmitReadyNotify.java
(rev 0)
+++ gnunet-java/org/gnunet/util/connection/TransmitReadyNotify.java
2011-11-01 18:30:36 UTC (rev 17894)
@@ -0,0 +1,5 @@
+package org.gnunet.util.connection;
+
+public interface TransmitReadyNotify {
+
+}
Added: gnunet-java/org/gnunet/util/time/AbsoluteTime.java
===================================================================
--- gnunet-java/org/gnunet/util/time/AbsoluteTime.java
(rev 0)
+++ gnunet-java/org/gnunet/util/time/AbsoluteTime.java 2011-11-01 18:30:36 UTC
(rev 17894)
@@ -0,0 +1,67 @@
+package org.gnunet.util.time;
+
+public class AbsoluteTime {
+
+ final static AbsoluteTime ZERO = new AbsoluteTime(0);
+ final static AbsoluteTime FOREVER = new AbsoluteTime(Long.MAX_VALUE);
+
+ private static long offset;
+
+ private final long abs_value;
+
+ public static void setOffset(long offset) {
+ throw new UnsupportedOperationException();
+ }
+
+ public AbsoluteTime() {
+ this.abs_value = System.currentTimeMillis();
+ }
+
+ public AbsoluteTime(long abs_value) {
+ this.abs_value = abs_value;
+ }
+
+ public AbsoluteTime min(AbsoluteTime other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public AbsoluteTime max(AbsoluteTime other) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public RelativeTime getRemaining() {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public RelativeTime calculateETA(AbsoluteTime start, long finished,
+ long total) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime getDifference(AbsoluteTime other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime getDuration(AbsoluteTime whence) {
+ throw new UnsupportedOperationException();
+ }
+
+ public AbsoluteTime add(RelativeTime duration) {
+ throw new UnsupportedOperationException();
+ }
+
+ public AbsoluteTime subtract(RelativeTime duration) {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte[] toNetwork() {
+ throw new UnsupportedOperationException();
+ }
+
+ static AbsoluteTime fromNetwork(byte[] b) {
+ throw new UnsupportedOperationException();
+ }
+
+}
Added: gnunet-java/org/gnunet/util/time/RelativeTime.java
===================================================================
--- gnunet-java/org/gnunet/util/time/RelativeTime.java
(rev 0)
+++ gnunet-java/org/gnunet/util/time/RelativeTime.java 2011-11-01 18:30:36 UTC
(rev 17894)
@@ -0,0 +1,62 @@
+package org.gnunet.util.time;
+
+public class RelativeTime {
+
+ final static RelativeTime MILLISECOND = new RelativeTime(1);
+ final static RelativeTime SECOND = MILLISECOND.multiply(1000);
+ final static RelativeTime MINUTE = SECOND.multiply(60);
+ final static RelativeTime HOUR = MINUTE.multiply(60);
+ final static RelativeTime DAY = HOUR.multiply(24);
+ final static RelativeTime WEEK = DAY.multiply(7);
+ final static RelativeTime MONTH = DAY.multiply(30);
+ final static RelativeTime YEAR = DAY.multiply(365);
+
+ final static RelativeTime FOREVER = new RelativeTime(Long.MAX_VALUE);
+
+ private final long abs_value;
+
+ public RelativeTime(long abs_value) {
+ this.abs_value = abs_value;
+ }
+
+ public AbsoluteTime toAbsolute() {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime min(RelativeTime other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime max(RelativeTime other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime multiply(int factor) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime divide(int factor) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime add(RelativeTime other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public RelativeTime subtract(RelativeTime other) {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte[] toNetwork() {
+ throw new UnsupportedOperationException();
+ }
+
+ static RelativeTime fromNetwork(byte[] b) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String toString() {
+ throw new UnsupportedOperationException();
+ }
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17894 - in gnunet-java: . org org/gnunet org/gnunet/service org/gnunet/util org/gnunet/util/connection org/gnunet/util/time,
gnunet <=