[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19996 - in gnunet-java: . .idea src src/org/gnunet/constru
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19996 - in gnunet-java: . .idea src src/org/gnunet/construct src/org/gnunet/construct/parsers src/org/gnunet/nse src/org/gnunet/statistics src/org/gnunet/util |
Date: |
Thu, 23 Feb 2012 21:33:22 +0100 |
Author: dold
Date: 2012-02-23 21:33:22 +0100 (Thu, 23 Feb 2012)
New Revision: 19996
Added:
gnunet-java/src/org/gnunet/statistics/Statistics.java
gnunet-java/src/org/gnunet/util/Cancelable.java
gnunet-java/statistics
Removed:
gnunet-java/src/log4j.properties
gnunet-java/src/org/gnunet/statistics/StatisticsService.java
Modified:
gnunet-java/.idea/workspace.xml
gnunet-java/ISSUES
gnunet-java/src/org/gnunet/construct/Construct.java
gnunet-java/src/org/gnunet/construct/MsgMap.txt
gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
gnunet-java/src/org/gnunet/nse/NetworkSizeEstimation.java
gnunet-java/src/org/gnunet/util/Client.java
gnunet-java/src/org/gnunet/util/Configuration.java
gnunet-java/src/org/gnunet/util/Program.java
gnunet-java/src/org/gnunet/util/Resolver.java
gnunet-java/src/org/gnunet/util/Scheduler.java
Log:
implemented parts of the statistics api, fixed some bugs
Modified: gnunet-java/.idea/workspace.xml
===================================================================
--- gnunet-java/.idea/workspace.xml 2012-02-23 19:21:56 UTC (rev 19995)
+++ gnunet-java/.idea/workspace.xml 2012-02-23 20:33:22 UTC (rev 19996)
@@ -1,14 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
- <list default="true" readonly="true"
id="54202f52-6f5b-4e71-983e-7aa49e206034" name="Default" comment="">
+ <list default="true" readonly="true"
id="54202f52-6f5b-4e71-983e-7aa49e206034" name="Default" comment="implemented
parts of the statistics api, fixed some bugs">
+ <change type="NEW" beforePath=""
afterPath="$PROJECT_DIR$/src/org/gnunet/util/Cancelable.java" />
+ <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/statistics" />
+ <change type="DELETED" beforePath="$PROJECT_DIR$/src/log4j.properties"
afterPath="" />
+ <change type="MOVED"
beforePath="$PROJECT_DIR$/src/org/gnunet/statistics/StatisticsService.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/statistics/Statistics.java" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/.idea/workspace.xml"
afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/ISSUES"
afterPath="$PROJECT_DIR$/ISSUES" />
- <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml"
afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" />
- <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/.idea/workspace.xml"
afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/construct/Construct.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/construct/Construct.java" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/construct/MsgMap.txt"
afterPath="$PROJECT_DIR$/src/org/gnunet/construct/MsgMap.txt" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/construct/parsers/IntegerParser.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/construct/parsers/IntegerParser.java" />
<change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/nse/NetworkSizeEstimation.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/nse/NetworkSizeEstimation.java" />
- <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/util/AbsoluteTime.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/util/AbsoluteTime.java" />
<change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/util/Client.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/util/Client.java" />
<change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/util/Configuration.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/util/Configuration.java" />
+ <change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/util/Program.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/util/Program.java" />
<change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/util/Resolver.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/util/Resolver.java" />
<change type="MODIFICATION"
beforePath="$PROJECT_DIR$/src/org/gnunet/util/Scheduler.java"
afterPath="$PROJECT_DIR$/src/org/gnunet/util/Scheduler.java" />
</list>
@@ -68,12 +74,21 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="Client.java" pinned="false" current="true"
current-in-tab="true">
+ <file leaf-file-name="Program.java" pinned="false" current="false"
current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Program.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="150" column="7" selection-start="4834"
selection-end="4834" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="Client.java" pinned="false" current="false"
current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Client.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="388" column="7" selection-start="13388"
selection-end="13388" vertical-scroll-proportion="0.03133903">
+ <state line="117" column="34" selection-start="4127"
selection-end="4127" vertical-scroll-proportion="0.0">
<folding>
- <element signature="e#0#16712#0" expanded="true" />
+ <element signature="e#0#18578#0" expanded="true" />
<element signature="imports" expanded="true" />
<element signature="e#1842#1855#0" expanded="true" />
</folding>
@@ -81,57 +96,50 @@
</provider>
</entry>
</file>
- <file leaf-file-name="Program.java" pinned="false" current="false"
current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Program.java">
+ <file leaf-file-name="MessageReceiver.java" pinned="false"
current="false" current-in-tab="false">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/MessageReceiver.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="33" selection-start="168"
selection-end="168" vertical-scroll-proportion="0.0">
+ <state line="42" column="32" selection-start="1274"
selection-end="1274" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="Resolver.java" pinned="false" current="false"
current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Resolver.java">
+ <file leaf-file-name="Parser.java" pinned="false" current="false"
current-in-tab="false">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/getopt/Parser.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="327" column="0" selection-start="9339"
selection-end="9339" vertical-scroll-proportion="0.0">
+ <state line="135" column="21" selection-start="4442"
selection-end="4442" vertical-scroll-proportion="33.32">
<folding>
- <element signature="e#707#763#0" expanded="true" />
+ <element signature="e#3478#3486#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="Scheduler.java" pinned="false" current="false"
current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Scheduler.java">
+ <file leaf-file-name="Statistics.java" pinned="false" current="true"
current-in-tab="true">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/statistics/Statistics.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="156" column="0" selection-start="5607"
selection-end="5607" vertical-scroll-proportion="0.0">
+ <state line="21" column="0" selection-start="514"
selection-end="514" vertical-scroll-proportion="0.41944847">
<folding>
- <element signature="e#0#23399#0" expanded="true" />
<element signature="imports" expanded="true" />
- <element signature="e#2344#2360#0" expanded="true" />
- <element signature="e#2411#2427#0" expanded="true" />
- <element signature="e#2480#2496#0" expanded="true" />
- <element signature="e#11055#11071#0" expanded="true" />
- <element signature="e#11424#11452#0" expanded="true" />
- <element signature="e#18976#18992#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="IOContinuation.java" pinned="false"
current="false" current-in-tab="false">
- <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/IOContinuation.java">
+ <file leaf-file-name="Option.java" pinned="false" current="false"
current-in-tab="false">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/getopt/Option.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="24" column="17" selection-start="863"
selection-end="863" vertical-scroll-proportion="0.0">
+ <state line="10" column="18" selection-start="277"
selection-end="277" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="Configuration.java" pinned="false" current="false"
current-in-tab="false">
- <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/Configuration.java">
+ <file leaf-file-name="Cancelable.java" pinned="false" current="false"
current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Cancelable.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="338" column="12" selection-start="10814"
selection-end="10814" vertical-scroll-proportion="0.0">
+ <state line="6" column="25" selection-start="173"
selection-end="173" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -140,39 +148,33 @@
<file leaf-file-name="ISSUES" pinned="false" current="false"
current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ISSUES">
<provider selected="true" editor-type-id="text-editor">
- <state line="223" column="41" selection-start="7938"
selection-end="7938" vertical-scroll-proportion="0.0">
+ <state line="227" column="44" selection-start="8237"
selection-end="8237" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="PriorityQueue.class" pinned="false"
current="false" current-in-tab="false">
- <entry
file="jar:///usr/lib/jvm/java-6-sun/jre/lib/rt.jar!/java/util/PriorityQueue.class">
+ <file leaf-file-name="Resolver.java" pinned="false" current="false"
current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Resolver.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="92" column="0" selection-start="3446"
selection-end="3446" vertical-scroll-proportion="0.0">
- <folding />
+ <state line="198" column="0" selection-start="5386"
selection-end="5386" vertical-scroll-proportion="-6.8">
+ <folding>
+ <element signature="e#785#841#0" expanded="true" />
+ <element signature="e#6967#6982#0" expanded="true" />
+ </folding>
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="RelativeTime.java" pinned="false" current="false"
current-in-tab="false">
- <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/RelativeTime.java">
+ <file leaf-file-name="MessageTransmitter.java" pinned="false"
current="false" current-in-tab="false">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/MessageTransmitter.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="187" column="0" selection-start="5781"
selection-end="5781" vertical-scroll-proportion="0.0">
+ <state line="2" column="17" selection-start="43"
selection-end="43" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="String.class" pinned="false" current="false"
current-in-tab="false">
- <entry
file="jar:///usr/lib/jvm/java-6-sun/jre/lib/alt-string.jar!/java/lang/String.class">
- <provider selected="true" editor-type-id="text-editor">
- <state line="200" column="35" selection-start="8213"
selection-end="8213" vertical-scroll-proportion="0.0">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
</leaf>
</component>
<component name="FindManager">
@@ -184,12 +186,19 @@
<option name="changedFiles">
<list>
<option value="$PROJECT_DIR$/src/org/gnunet/util/AbsoluteTime.java" />
+ <option
value="$PROJECT_DIR$/src/org/gnunet/statistics/StatisticsService.java" />
+ <option value="$PROJECT_DIR$/src/org/gnunet/util/Configuration.java" />
+ <option value="$PROJECT_DIR$/src/org/gnunet/util/Scheduler.java" />
<option
value="$PROJECT_DIR$/src/org/gnunet/nse/NetworkSizeEstimation.java" />
- <option value="$PROJECT_DIR$/src/org/gnunet/util/Configuration.java" />
- <option value="$PROJECT_DIR$/ISSUES" />
+ <option value="$PROJECT_DIR$/src/org/gnunet/construct/Construct.java"
/>
+ <option
value="$PROJECT_DIR$/src/org/gnunet/construct/parsers/IntegerParser.java" />
+ <option value="$PROJECT_DIR$/src/org/gnunet/util/Cancelable.java" />
+ <option value="$PROJECT_DIR$/src/org/gnunet/util/Program.java" />
<option value="$PROJECT_DIR$/src/org/gnunet/util/Resolver.java" />
- <option value="$PROJECT_DIR$/src/org/gnunet/util/Scheduler.java" />
+ <option value="$PROJECT_DIR$/src/org/gnunet/util/MessageReceiver.java"
/>
<option value="$PROJECT_DIR$/src/org/gnunet/util/Client.java" />
+ <option value="$PROJECT_DIR$/ISSUES" />
+ <option
value="$PROJECT_DIR$/src/org/gnunet/statistics/Statistics.java" />
</list>
</option>
</component>
@@ -225,6 +234,8 @@
<sortByType />
</navigator>
<panes>
+ <pane id="Scope" />
+ <pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<PATH>
@@ -253,9 +264,13 @@
<option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
- <option name="myItemId" value="src" />
+ <option name="myItemId" value="test" />
<option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -326,11 +341,161 @@
<option name="myItemId" value="gnunet" />
<option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="util" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="getopt" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="org" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="statistics" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="org" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="nse" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="org" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="org" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="construct" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="src" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="org" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="construct" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="parsers" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="gnunet-java" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value=".idea" />
+ <option name="myItemType"
value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
</subPane>
</pane>
- <pane id="Scope" />
- <pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
@@ -502,23 +667,24 @@
</component>
<component name="ToolWindowManager">
<frame x="-6" y="17" width="1452" height="889" extended-state="0" />
- <editor active="true" />
+ <editor active="false" />
<layout>
- <window_info id="Messages" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.32967034" sideWeight="0.5" order="7" side_tool="false"
content_ui="tabs" />
<window_info id="Changes" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="SVN Properties" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.32967034" sideWeight="0.5" order="-1" side_tool="false"
content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
- <window_info id="TODO" active="false" anchor="bottom" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33"
sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
- <window_info id="Structure" active="false" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true"
weight="0.25685427" sideWeight="0.28983516" order="1" side_tool="true"
content_ui="tabs" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25685427"
sideWeight="0.7005494" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32967034"
sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="false" weight="0.17582418"
sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
+ <window_info id="Event Log" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
- <window_info id="Event Log" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
+ <window_info id="Version Control" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
+ <window_info id="Messages" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.15521978" sideWeight="0.5" order="7" side_tool="false"
content_ui="tabs" />
+ <window_info id="TODO" active="false" anchor="bottom" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33"
sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
+ <window_info id="Structure" active="false" anchor="left"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true"
weight="0.26046175" sideWeight="0.2293956" order="1" side_tool="true"
content_ui="tabs" />
+ <window_info id="Project" active="true" anchor="left" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="true" weight="0.26046175"
sideWeight="0.760989" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3021978"
sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
- <window_info id="Version Control" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25"
sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false"
internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32967034"
sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom"
auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false"
weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
@@ -558,7 +724,7 @@
<option name="INCLUDE_TEXT_INTO_SHELF" value="false" />
<option name="CREATE_PATCH_EXPAND_DETAILS_DEFAULT" value="true" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
- <option name="LAST_COMMIT_MESSAGE" />
+ <option name="LAST_COMMIT_MESSAGE" value="fixed the very buggy
implementation of the client; added some stuff to the scheduler" />
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="true" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
@@ -571,6 +737,7 @@
<option name="UPDATE_GROUP_BY_CHANGELIST" value="false" />
<option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
<option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
+ <MESSAGE value="fixed the very buggy implementation of the client; added
some stuff to the scheduler" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
@@ -580,114 +747,125 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/AbsoluteTime.java">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/construct/MessageLoader.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="218" column="0" selection-start="6135"
selection-end="6135" vertical-scroll-proportion="0.0" />
+ <state line="37" column="13" selection-start="1177"
selection-end="1177" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry
file="jar:///usr/lib/jvm/java-6-sun/jre/lib/rt.jar!/java/nio/channels/SocketChannel.class">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/construct/MessageHeader.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="23" column="28" selection-start="1053"
selection-end="1053" vertical-scroll-proportion="0.0">
+ <state line="13" column="0" selection-start="217" selection-end="217"
vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/MessageTransmitter.java">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/nse/NetworkSizeEstimation.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="2" column="17" selection-start="43" selection-end="43"
vertical-scroll-proportion="0.0" />
+ <state line="20" column="0" selection-start="410" selection-end="517"
vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry
file="file://$PROJECT_DIR$/src/org/gnunet/nse/NetworkSizeEstimation.java">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/construct/Construct.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="173" column="51" selection-start="4600"
selection-end="4600" vertical-scroll-proportion="0.0" />
+ <state line="36" column="10" selection-start="1140"
selection-end="1140" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/AbsoluteTimeMessage.java">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/construct/parsers/NestedParser.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="6" column="13" selection-start="114" selection-end="114"
vertical-scroll-proportion="0.0" />
+ <state line="10" column="13" selection-start="239" selection-end="239"
vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Program.java">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/construct/parsers/IntegerParser.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="33" selection-start="168" selection-end="168"
vertical-scroll-proportion="0.0">
+ <state line="201" column="23" selection-start="6493"
selection-end="6493" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry
file="jar:///usr/lib/jvm/java-6-sun/jre/lib/rt.jar!/java/util/PriorityQueue.class">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/getopt/Option.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="92" column="0" selection-start="3446"
selection-end="3446" vertical-scroll-proportion="0.0">
+ <state line="10" column="18" selection-start="277" selection-end="277"
vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/ISSUES">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/getopt/Parser.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="223" column="41" selection-start="7938"
selection-end="7938" vertical-scroll-proportion="0.0">
- <folding />
+ <state line="135" column="21" selection-start="4442"
selection-end="4442" vertical-scroll-proportion="33.32">
+ <folding>
+ <element signature="e#3478#3486#0" expanded="true" />
+ </folding>
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/RelativeTime.java">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Cancelable.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="187" column="0" selection-start="5781"
selection-end="5781" vertical-scroll-proportion="0.0">
+ <state line="6" column="25" selection-start="173" selection-end="173"
vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry
file="jar:///usr/lib/jvm/java-6-sun/jre/lib/alt-string.jar!/java/lang/String.class">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Program.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="200" column="35" selection-start="8213"
selection-end="8213" vertical-scroll-proportion="0.0">
+ <state line="150" column="7" selection-start="4834"
selection-end="4834" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/IOContinuation.java">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Resolver.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="24" column="17" selection-start="863" selection-end="863"
vertical-scroll-proportion="0.0">
- <folding />
+ <state line="198" column="0" selection-start="5386"
selection-end="5386" vertical-scroll-proportion="-6.8">
+ <folding>
+ <element signature="e#785#841#0" expanded="true" />
+ <element signature="e#6967#6982#0" expanded="true" />
+ </folding>
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Configuration.java">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/MessageTransmitter.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="338" column="12" selection-start="10814"
selection-end="10814" vertical-scroll-proportion="0.0">
+ <state line="2" column="17" selection-start="43" selection-end="43"
vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Resolver.java">
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/util/MessageReceiver.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="327" column="0" selection-start="9339"
selection-end="9339" vertical-scroll-proportion="0.0">
- <folding>
- <element signature="e#707#763#0" expanded="true" />
- </folding>
+ <state line="42" column="32" selection-start="1274"
selection-end="1274" vertical-scroll-proportion="0.0">
+ <folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Scheduler.java">
+ <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Client.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="156" column="0" selection-start="5607"
selection-end="5607" vertical-scroll-proportion="0.0">
+ <state line="117" column="34" selection-start="4127"
selection-end="4127" vertical-scroll-proportion="0.0">
<folding>
- <element signature="e#0#23399#0" expanded="true" />
+ <element signature="e#0#18578#0" expanded="true" />
<element signature="imports" expanded="true" />
- <element signature="e#2344#2360#0" expanded="true" />
- <element signature="e#2411#2427#0" expanded="true" />
- <element signature="e#2480#2496#0" expanded="true" />
- <element signature="e#11055#11071#0" expanded="true" />
- <element signature="e#11424#11452#0" expanded="true" />
- <element signature="e#18976#18992#0" expanded="true" />
+ <element signature="e#1842#1855#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/org/gnunet/util/Client.java">
+ <entry file="file://$PROJECT_DIR$/ISSUES">
<provider selected="true" editor-type-id="text-editor">
- <state line="388" column="7" selection-start="13388"
selection-end="13388" vertical-scroll-proportion="0.03133903">
+ <state line="227" column="44" selection-start="8237"
selection-end="8237" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry
file="file://$PROJECT_DIR$/src/org/gnunet/statistics/Statistics.java">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="21" column="0" selection-start="514" selection-end="514"
vertical-scroll-proportion="0.41944847">
<folding>
- <element signature="e#0#16712#0" expanded="true" />
<element signature="imports" expanded="true" />
- <element signature="e#1842#1855#0" expanded="true" />
</folding>
</state>
</provider>
Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES 2012-02-23 19:21:56 UTC (rev 19995)
+++ gnunet-java/ISSUES 2012-02-23 20:33:22 UTC (rev 19996)
@@ -222,4 +222,10 @@
* what are use cases for the scheduler's priorities?
* should shutdown really be a reason, not a separate callback-method in Task?
- * some tasks re-schedule themselves, it's very easy to forget checking the
shutdown flag in the context
\ No newline at end of file
+ * some tasks re-schedule themselves, it's very easy to forget checking the
shutdown flag in the context
+ * how should a disconnect from the service be handeled?
+ * probably there should be a callback for this, too
+ * service clients should try to re-connect
+ * should we introduce a general interface "Cancelable" for requests?
+ * what is the persistence in statistics? (esp. in the watch message)
+ * general api question: should callbacks have their corresponding request
handler passed?
\ No newline at end of file
Deleted: gnunet-java/src/log4j.properties
===================================================================
--- gnunet-java/src/log4j.properties 2012-02-23 19:21:56 UTC (rev 19995)
+++ gnunet-java/src/log4j.properties 2012-02-23 20:33:22 UTC (rev 19996)
@@ -1,6 +0,0 @@
-log4j.rootLogger=WARN, A1
-
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-5p %c:\n%m%n
Modified: gnunet-java/src/org/gnunet/construct/Construct.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/Construct.java 2012-02-23 19:21:56 UTC
(rev 19995)
+++ gnunet-java/src/org/gnunet/construct/Construct.java 2012-02-23 20:33:22 UTC
(rev 19996)
@@ -33,6 +33,15 @@
Class<T> c) {
T m;
+
+ /*
+ if (c.isMemberClass()) {
+ throw new InterfaceViolationException("cannot instantiaze member
class " + c.getCanonicalName()
+ + ": please make it static)");
+ }
+ */
+
+
try {
m = c.newInstance();
} catch (InstantiationException e) {
@@ -78,7 +87,7 @@
private static Parser getParser(Class<? extends Message> c,
ParserGenerator pg) {
-
+
SequenceParser parser = new SequenceParser();
pg.c = c;
@@ -217,7 +226,7 @@
List<Field> old_path = new ArrayList<Field>(path);
path.add(field);
-
+
Class old_c = c;
Parser p = getParser(ct, this);
Modified: gnunet-java/src/org/gnunet/construct/MsgMap.txt
===================================================================
--- gnunet-java/src/org/gnunet/construct/MsgMap.txt 2012-02-23 19:21:56 UTC
(rev 19995)
+++ gnunet-java/src/org/gnunet/construct/MsgMap.txt 2012-02-23 20:33:22 UTC
(rev 19996)
@@ -1,4 +1,8 @@
5=org.gnunet.util.Resolver$ResolverResponse
+171=org.gnunet.statistics.Statistics$ResponseEndMessage
+170=org.gnunet.statistics.Statistics$ResponseValueMessage
+169=org.gnunet.statistics.Statistics$RequestMessage
+168=org.gnunet.statistics.Statistics$SetMessage
291=org.gnunet.construct.QueryMessage
323=org.gnunet.nse.NetworkSizeEstimation$NSE_UpdateMessage
321=org.gnunet.nse.NetworkSizeEstimation$NSE_StartMessage
@@ -8,4 +12,4 @@
1|org.gnunet.construct.UnionTest.TestUnion=org.gnunet.construct.UnionTest$TestUnionCase1
0|org.gnunet.util.Resolver.AddressUnion=org.gnunet.util.Resolver$TextualAddress
1|org.gnunet.util.Resolver.AddressUnion=org.gnunet.util.Resolver$NumericAddress
-# generated 2012/01/27 18:56:31
+# generated 2012/02/23 21:30:09
Modified: gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
===================================================================
--- gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
2012-02-23 19:21:56 UTC (rev 19995)
+++ gnunet-java/src/org/gnunet/construct/parsers/IntegerParser.java
2012-02-23 20:33:22 UTC (rev 19996)
@@ -4,6 +4,7 @@
import org.gnunet.construct.Message;
import java.lang.reflect.Field;
+import java.math.BigInteger;
import java.util.Arrays;
public class IntegerParser extends FieldParser {
@@ -18,7 +19,7 @@
private ReflectionUtil.NumFieldType ft;
public IntegerParser(final int byteSize, final boolean isSigned,
- final Field f) {
+ final Field f) {
super(f);
this.byteSize = byteSize;
this.isSigned = isSigned;
@@ -36,22 +37,23 @@
Message frameObj, final Message dstObj) {
try {
switch (ft) {
- case BYTE_PRIM:
- field.setByte(dstObj, readByte(srcData, offset));
- break;
- case SHORT_PRIM:
- field.setShort(dstObj, readShort(srcData, offset));
- break;
- case INT_PRIM:
- field.setInt(dstObj, readInt(srcData, offset));
- break;
- case LONG_PRIM:
- field.setLong(dstObj, readLong(srcData, offset));
- break;
- case BIGNUM: case CHAR_PRIM:
+ case BYTE_PRIM:
+ field.setByte(dstObj, readByte(srcData, offset));
+ break;
+ case SHORT_PRIM:
+ field.setShort(dstObj, (short) readLong(srcData, offset));
+ break;
+ case INT_PRIM:
+ field.setInt(dstObj, (int) readLong(srcData, offset));
+ break;
+ case LONG_PRIM:
+ field.setLong(dstObj, readLong(srcData, offset));
+ break;
+ case BIGNUM:
+ case CHAR_PRIM:
throw new UnsupportedOperationException("not yet
implemented");
- default:
- throw new RuntimeException("invalid member type");
+ default:
+ throw new RuntimeException("invalid member type");
}
} catch (IllegalArgumentException e) {
@@ -65,7 +67,7 @@
@Override
public int write(final byte[] dstData, final int offset,
- final Message srcObj) {
+ final Message srcObj) {
try {
switch (ft) {
@@ -81,7 +83,8 @@
case LONG_PRIM:
writeLong(field.getLong(srcObj), dstData, offset);
break;
- case BIGNUM: case CHAR_PRIM:
+ case BIGNUM:
+ case CHAR_PRIM:
throw new UnsupportedOperationException("not yet
implemented");
default:
throw new RuntimeException("invalid member type: ");
@@ -178,59 +181,38 @@
return val;
}
- public short readShort(byte[] data, int offset) {
- short val = 0;
- // MSB is at lower address in NBO
- if (byteSize - 2 >= 0) {
- val = data[offset + (byteSize - 2)];
+ public long readLong(byte[] data, int offset) {
+ long val = 0;
+
+ int pos = offset;
+ while (pos < offset + byteSize - 1) {
+ byte b = data[pos];
+ int s = b >= 0 ? b : (256 + b);
+
+ val |= s;
val <<= 8;
- }
- val |= data[offset + (byteSize - 1)];
- if (isSigned) {
- // explicitly OR sign bit to the right place if the source buffer
is
- // too large
- byte sign = (byte) (data[offset] & 0x80);
- val |= sign;
- }
- return val;
- }
- public int readInt(byte[] data, int offset) {
- int val = 0;
- // MSB is at lower address in NBO
- for (int i = 4; i >= 2; --i) {
- if (byteSize - i >= 0) {
- val = data[offset + (byteSize - i)];
- val <<= 8;
- }
+ pos += 1;
}
- val |= data[offset + (byteSize - 1)];
+
+ byte b = data[pos];
+ int s = b >= 0 ? b : (256 + b);
+ val |= s;
+
if (isSigned) {
// explicitly OR sign bit to the right place if the source buffer
is
// too large
- byte sign = (byte) (data[offset] & 0x80);
- val |= sign;
+ long sign = (data[offset] & 0x80);
+ val |= (sign << 7);
}
+
return val;
}
- public long readLong(byte[] data, int offset) {
- long val = 0;
- // MSB is at lower address in NBO
- for (int i = 8; i >= 2; --i) {
- if (byteSize - i >= 0) {
- val = data[offset + (byteSize - i)];
- val <<= 8;
- }
- }
- val |= data[offset + (byteSize - 1)];
- if (isSigned) {
- // explicitly OR sign bit to the right place if the source buffer
is
- // too large
- byte sign = (byte) (data[offset] & 0x80);
- val |= sign;
- }
- return val;
+
+ public BigInteger readBigInteger(byte[] data, int offset) {
+ // todo: implement
+ return null;
}
}
Modified: gnunet-java/src/org/gnunet/nse/NetworkSizeEstimation.java
===================================================================
--- gnunet-java/src/org/gnunet/nse/NetworkSizeEstimation.java 2012-02-23
19:21:56 UTC (rev 19995)
+++ gnunet-java/src/org/gnunet/nse/NetworkSizeEstimation.java 2012-02-23
20:33:22 UTC (rev 19996)
@@ -27,7 +27,6 @@
private Client client;
-
@SuppressWarnings("InstanceVariableMayNotBeInitialized")
@MessageId(NSE_StartMessage.MSG_ID)
public static class NSE_StartMessage implements Message {
@@ -60,7 +59,6 @@
}
-
private class NSE_Receiver implements MessageReceiver {
@Override
public void process(Message msg) {
@@ -74,7 +72,7 @@
}
if (!disconnected) {
- client.receive(this, RelativeTime.FOREVER);
+ client.receive(RelativeTime.FOREVER, this);
}
}
@@ -95,7 +93,7 @@
m.header.messageType = NSE_StartMessage.MSG_ID;
m.header.messageSize = MessageHeader.SIZE;
sink.send(m);
- client.receive(new NSE_Receiver(), RelativeTime.FOREVER);
+ client.receive(RelativeTime.FOREVER, new NSE_Receiver());
}
@Override
@@ -154,6 +152,7 @@
*/
public NetworkSizeEstimation(Configuration cfg) {
client = new Client("nse", cfg);
+ logger.debug("lifeness in NSE ctor: {}",
Scheduler.getCurrentLifeness());
client.notifyTransmitReady(RelativeTime.FOREVER, true, new
NSE_Transmitter());
}
@@ -164,32 +163,26 @@
disconnected = true;
client.disconnect();
}
-
- public static void main (String[] args)
- {
- new Program (args) {
-
- public int f_foo; // shortname: f, long name: foo, type: "int"
-
- public boolean b_bar; // shortname: b, long name: bar, type:
boolean flag (present: true, absent: false)
- // or with annotations...
-
- public void run ()
- {
- final NetworkSizeEstimation svc = new
NetworkSizeEstimation(cfg);
- NSE_Subscriber subscriber = new NSE_Subscriber() {
- @Override
- public void update(AbsoluteTime timestamp, double estimate,
double deviation) {
- System.out.println("est:" + estimate + " dev: " +
deviation + " t: ");
- svc.disconnect();
- }
- };
- svc.subscribe(subscriber);
-
- }
- }.start();
-
-
+
+ public static void main(String[] args) {
+ new Program(args) {
+ public void run() {
+ final NetworkSizeEstimation svc = new
NetworkSizeEstimation(cfg);
+
+ NSE_Subscriber subscriber = new NSE_Subscriber() {
+ @Override
+ public void update(AbsoluteTime timestamp, double
estimate, double deviation) {
+ System.out.println("est:" + estimate + " dev: " +
deviation + " t: ");
+ svc.disconnect();
+ }
+ };
+
+ svc.subscribe(subscriber);
+
+ }
+ }.start();
+
+
}
-
+
}
Copied: gnunet-java/src/org/gnunet/statistics/Statistics.java (from rev 19840,
gnunet-java/src/org/gnunet/statistics/StatisticsService.java)
===================================================================
--- gnunet-java/src/org/gnunet/statistics/Statistics.java
(rev 0)
+++ gnunet-java/src/org/gnunet/statistics/Statistics.java 2012-02-23
20:33:22 UTC (rev 19996)
@@ -0,0 +1,250 @@
+/*
+ * The stuff below does nothing whatsoever, first milestone of
+ * this project is to implement the StatisticsService api
+ *
+ */
+
+package org.gnunet.statistics;
+
+import org.gnunet.construct.*;
+import org.gnunet.util.*;
+import org.gnunet.util.getopt.Option;
+import org.gnunet.util.getopt.OptionAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Statistics {
+ private static final Logger logger = LoggerFactory
+ .getLogger(Statistics.class);
+
+
+ private Client client;
+
+ @MessageId(RequestMessage.MSG_ID)
+ public static class RequestMessage implements Message {
+ public static final int MSG_ID = 169;
+ @Nested
+ public MessageHeader header;
+ @ZeroTerminatedString
+ public String subsystemName;
+ @ZeroTerminatedString
+ public String statisticsName;
+ }
+
+ @MessageId(ResponseValueMessage.MSG_ID)
+ public static class ResponseValueMessage implements Message {
+ public static final int MSG_ID = 170;
+ @Nested
+ public MessageHeader header;
+ @UInt32
+ public long uid;
+ @UInt64
+ public long value;
+ @ZeroTerminatedString
+ public String subsystemName;
+ @ZeroTerminatedString
+ public String statisticName;
+ }
+
+ @MessageId(ResponseEndMessage.MSG_ID)
+ public static class ResponseEndMessage implements Message {
+ public static final int MSG_ID = 171;
+ @Nested
+ public MessageHeader header;
+ }
+
+ @MessageId(SetMessage.MSG_ID)
+ public static class SetMessage implements Message {
+ public static final int MSG_ID = 168;
+ @Nested
+ public MessageHeader header;
+ @UInt32
+ public int flags;
+ @UInt64
+ public long value;
+ @ZeroTerminatedString
+ public String subsystemName;
+ @ZeroTerminatedString
+ public String statisticName;
+
+ }
+
+ public Statistics(Configuration cfg) {
+ client = new Client("statistics", cfg);
+ }
+
+
+ public interface StatisticsReceiver {
+ public void onReceive(String subsystem, String name, long value);
+
+ public void onTimeout();
+
+ public void onDone();
+ }
+
+ public Cancelable get(RelativeTime timeout, final String subsystem, final
String name, final StatisticsReceiver srh) {
+ final AbsoluteTime deadline = timeout.toAbsolute();
+
+ client.notifyTransmitReady(deadline.getRemaining(), true, new
MessageTransmitter() {
+ @Override
+ public void transmit(Client.MessageSink sink) {
+ RequestMessage rm = new RequestMessage();
+ rm.header = new MessageHeader();
+ rm.statisticsName = name;
+ rm.subsystemName = subsystem;
+ rm.header.messageType = RequestMessage.MSG_ID;
+ rm.header.messageSize = Construct.getSize(rm);
+
+ sink.send(rm);
+
+
+ client.receive(deadline.getRemaining(), new MessageReceiver() {
+ @Override
+ public void process(Message msg) {
+ if (msg instanceof ResponseValueMessage) {
+ ResponseValueMessage rvm = (ResponseValueMessage)
msg;
+ srh.onReceive(rvm.subsystemName,
rvm.statisticName, rvm.value);
+ client.receive(deadline.getRemaining(), this);
+ } else if (msg instanceof ResponseEndMessage) {
+ srh.onDone();
+ logger.info("all statistics received");
+ } else {
+ logger.error("message format error in response
from the service");
+ }
+ }
+
+ @Override
+ public void handleTimeout() {
+ logger.error("unable to read from statistics service");
+ }
+ });
+ }
+
+ @Override
+ public void handleTimeout() {
+ logger.error("unable to connect to statistics service");
+ }
+ });
+ return null;
+ }
+
+ public Cancelable get(RelativeTime timeout, StatisticsReceiver srh) {
+ return get(timeout, "", "", srh);
+ }
+
+ public interface SetCompleted {
+ public void onCompleted();
+
+ public void onTimeout();
+ }
+
+
+ public Cancelable set(RelativeTime timeout, final String subsystem, final
String name, final long value,
+ final SetCompleted cb) {
+ client.notifyTransmitReady(timeout, true, new MessageTransmitter() {
+
+ @Override
+ public void transmit(Client.MessageSink sink) {
+ SetMessage sm = new SetMessage();
+ sm.statisticName = name;
+ sm.subsystemName = subsystem;
+ sm.value = value;
+ sm.header = new MessageHeader();
+ sm.header.messageType = SetMessage.MSG_ID;
+ sm.header.messageSize = Construct.getSize(sm);
+
+ sink.send(sm);
+
+ cb.onCompleted();
+ }
+
+ @Override
+ public void handleTimeout() {
+ cb.onTimeout();
+ }
+ });
+ return new Cancelable() {
+ @Override
+ public void cancel() {
+ throw new UnsupportedOperationException("not yet implementd");
+ }
+ };
+ }
+
+ public static void main(String[] args) {
+
+ new Program(args) {
+ @Option(
+ shortname = "x",
+ longname = "set",
+ action = OptionAction.SET,
+ description = "set a value")
+ boolean test;
+ @Option(
+ shortname = "n",
+ longname = "name",
+ action = OptionAction.STORE_STRING,
+ description = "statistics name")
+ String statisticsName = "";
+ @Option(
+ shortname = "s",
+ longname = "subsystem",
+ action = OptionAction.STORE_STRING,
+ description = "subsystem name")
+ String subsystemName = "";
+
+ public void run() {
+ Statistics statistics = new Statistics(cfg);
+ if (test) {
+ if (subsystemName.isEmpty() || statisticsName.isEmpty()) {
+ System.err.println("must specify non-empty subsystem
and name");
+ return;
+ }
+ if (unprocessedArgs.length != 1) {
+ System.err.println("must specify exactly one value to
set");
+ return;
+ }
+ long value;
+ try {
+ value = Long.parseLong(unprocessedArgs[0]);
+ } catch (NumberFormatException e) {
+ System.err.println("invalid value (not a long)");
+ return;
+ }
+ statistics.set(RelativeTime.SECOND, subsystemName,
statisticsName, value, new SetCompleted() {
+ @Override
+ public void onCompleted() {
+ System.out.println("done.");
+ }
+
+ @Override
+ public void onTimeout() {
+ System.out.println("timeout while setting");
+ }
+ });
+ } else {
+ if (unprocessedArgs.length != 0) {
+ System.err.println("dumping statistics does not take
any positional parameters");
+ } else {
+ statistics.get(RelativeTime.SECOND, subsystemName,
statisticsName, new StatisticsReceiver() {
+ @Override
+ public void onReceive(String subsystem, String
name, long value) {
+ System.out.println(subsystem + "(" + name + ")
= " + value);
+ }
+
+ @Override
+ public void onTimeout() {
+ logger.error("timeout while getting
statistics");
+ }
+
+ @Override
+ public void onDone() {
+ logger.info("done getting statistics");
+ }
+ });
+ }
+ }
+ }
+ }.start();
+ }
+}
Deleted: gnunet-java/src/org/gnunet/statistics/StatisticsService.java
===================================================================
--- gnunet-java/src/org/gnunet/statistics/StatisticsService.java
2012-02-23 19:21:56 UTC (rev 19995)
+++ gnunet-java/src/org/gnunet/statistics/StatisticsService.java
2012-02-23 20:33:22 UTC (rev 19996)
@@ -1,17 +0,0 @@
-/*
- * The stuff below does nothing whatsoever, first milestone of
- * this project is to implement the StatisticsService api
- *
- */
-
-package org.gnunet.statistics;
-
-import org.gnunet.util.Client;
-import org.gnunet.util.Configuration;
-
-public class StatisticsService {
-
- public StatisticsService(Configuration cfg) {
- Client client = new Client("statistics", cfg);
- }
-}
Added: gnunet-java/src/org/gnunet/util/Cancelable.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Cancelable.java
(rev 0)
+++ gnunet-java/src/org/gnunet/util/Cancelable.java 2012-02-23 20:33:22 UTC
(rev 19996)
@@ -0,0 +1,8 @@
+package org.gnunet.util;
+
+/**
+ * Any asynchronous operation that can be canceled should implement this
interface.
+ */
+public interface Cancelable {
+ public void cancel();
+}
Modified: gnunet-java/src/org/gnunet/util/Client.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Client.java 2012-02-23 19:21:56 UTC (rev
19995)
+++ gnunet-java/src/org/gnunet/util/Client.java 2012-02-23 20:33:22 UTC (rev
19996)
@@ -68,7 +68,6 @@
private boolean resolveActive;
-
/**
* Represents a request for transmission.
*/
@@ -111,10 +110,16 @@
public void run(Scheduler.RunContext ctx) {
logger.debug("receiving in helper");
if (ctx.reasons.contains(Scheduler.Reason.TIMEOUT)) {
+ currentReceiveHelper = null;
receiver.handleTimeout();
} else if (ctx.reasons.contains(Scheduler.Reason.READ_READY)) {
try {
int n = chan.read(recvBuffer);
+ if (n == -1) {
+ logger.error("end of stream in channel before complete
message, read {} bytes",
+ recvBuffer.position());
+ return;
+ }
logger.debug(String.format("chan read %s bytes", n));
} catch (IOException e) {
throw new RuntimeException("read failed");
@@ -174,8 +179,6 @@
@Override
public void run(Scheduler.RunContext ctx) {
-
-
try {
int n = chan.write(transmitBuffer);
logger.debug("chan has written " + n + " bytes");
@@ -186,7 +189,13 @@
logger.debug("sent " + transmitBuffer.position() + "bytes
complete message");
if (nextTransmitHelper == null) {
currentTransmitHelper = null;
+ if (currentTransmitTimeout != null) {
+ throw new AssertionError("error in timeout logic");
+ }
} else {
+ if (currentTransmitTimeout != null) {
+ throw new AssertionError("error in timeout logic");
+ }
nextTransmitTimeout.cancel();
currentTransmitHelper = nextTransmitHelper;
nextTransmitHelper.start();
@@ -210,7 +219,7 @@
});
b.withLifeness(desiredLifeness);
Scheduler.add(b);
-
+
}
private void schedule() {
@@ -347,6 +356,7 @@
if (connected) {
if (currentTransmitHelper != null) {
currentTransmitTimeout.cancel();
+ currentTransmitTimeout = null;
currentTransmitHelper.start();
}
}
@@ -380,14 +390,18 @@
connectNextAddress();
}
+ public interface ReceiveHandle {
+ public void cancel();
+ }
+
/**
* Receive one message from the service.
*
+ * @param timeout deadline after which MessageReceiver.deadline will be
called
* @param receiver MessageReceiver that is responsible for the received
message
- * @param timeout deadline after which MessageReceiver.deadline will be
called
*/
- public void receive(MessageReceiver receiver, RelativeTime timeout) {
+ public ReceiveHandle receive(RelativeTime timeout, MessageReceiver
receiver) {
if (currentReceiveHelper != null) {
throw new InterfaceViolationException("receive must not be called
while receiving");
}
@@ -396,21 +410,38 @@
recvBuffer.clear();
recvBuffer.limit(MessageHeader.SIZE);
- currentReceiveHelper = new ReceiveHelper(receiver, timeout);
+ final ReceiveHelper rh = new ReceiveHelper(receiver, timeout);
+ currentReceiveHelper = rh;
currentReceiveHelper.schedule();
+
+
+ return new ReceiveHandle() {
+ @Override
+ public void cancel() {
+ rh.cancel();
+ }
+ };
}
- public Scheduler.TaskIdentifier scheduleTransmitTimeout(final
MessageTransmitter t, RelativeTime timeout) {
- Scheduler.TaskBuilder b = new Scheduler.TaskBuilder();
- b.withTask(new Task() {
- @Override
- public void run(Scheduler.RunContext ctx) {
- t.handleTimeout();
+ public Scheduler.TaskIdentifier scheduleTransmitTimeout(final
MessageTransmitter t, RelativeTime timeout,
+ final boolean
forCurrent) {
+ Scheduler.TaskBuilder b = new Scheduler.TaskBuilder();
+ b.withTask(new Task() {
+ @Override
+ public void run(Scheduler.RunContext ctx) {
+ if (forCurrent) {
+ currentTransmitHelper.cancel();
+ currentTransmitHelper = null;
+ } else {
+ nextTransmitHelper.cancel();
+ nextTransmitHelper = null;
}
- });
- b.withTimeout(timeout);
- return Scheduler.add(b);
+ t.handleTimeout();
+ }
+ });
+ b.withTimeout(timeout);
+ return Scheduler.add(b);
}
@@ -435,18 +466,28 @@
"previous transmit request must have completed before
calling notifyTransmitReady again");
}
+ if (timeout.getMilliseconds() <= 0) {
+ transmitter.handleTimeout();
+ }
+ logger.debug("notifyTransmitReady with timeout {}", timeout);
+
+ logger.debug("lifeness notifyTransmitReady {}",
Scheduler.getCurrentLifeness());
+
+
final TransmitHelper transmit = new TransmitHelper(transmitter,
Scheduler.getCurrentLifeness());
if (currentTransmitHelper == null) {
currentTransmitHelper = transmit;
- currentTransmitTimeout = scheduleTransmitTimeout(transmitter,
timeout);
if (chan.isConnected()) {
+ currentTransmitTimeout = null;
currentTransmitHelper.start();
+ } else {
+ currentTransmitTimeout = scheduleTransmitTimeout(transmitter,
timeout, true);
}
} else {
nextTransmitHelper = transmit;
- nextTransmitTimeout = scheduleTransmitTimeout(transmitter,
timeout);
+ nextTransmitTimeout = scheduleTransmitTimeout(transmitter,
timeout, false);
}
@@ -467,6 +508,15 @@
if (currentTransmitHelper != null) {
currentTransmitHelper.cancel();
}
+ if (currentTransmitTimeout != null) {
+ currentTransmitTimeout.cancel();
+ }
+ if (nextTransmitHelper != null) {
+ nextTransmitHelper.cancel();
+ }
+ if (nextTransmitTimeout != null) {
+ nextTransmitTimeout.cancel();
+ }
if (currentReceiveHelper != null) {
currentReceiveHelper.cancel();
}
Modified: gnunet-java/src/org/gnunet/util/Configuration.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Configuration.java 2012-02-23 19:21:56 UTC
(rev 19995)
+++ gnunet-java/src/org/gnunet/util/Configuration.java 2012-02-23 20:33:22 UTC
(rev 19996)
@@ -59,6 +59,8 @@
private static Pattern whitspace = Pattern.compile("\\s*");
private final Map<String, Map<String, String>> sections = new
LinkedHashMap<String, Map<String, String>>(100);
+
+ private final Map<String, Set<String>> sectionSources = new
HashMap<String, Set<String>>(20);
/**
* Start with an empty configuration.
@@ -150,6 +152,7 @@
public long getValueNumer(String section, String option) {
String num_str = getValueString(section, option);
if (num_str == null) {
+ logSectionSources(section);
throw new ParsingError("Failure in configuration section "
+ section + " option " + option + ": value empty");
}
@@ -160,6 +163,15 @@
+ section + " option " + option + ": " + e.getMessage(),
e);
}
}
+
+ private void logSectionSources(String section) {
+ Set<String> sources = sectionSources.get(section);
+ if (sources == null) {
+ logger.info("No sources for section '{}'", section);
+ } else {
+ logger.info("Sources for section '{}': {}", section, sources);
+ }
+ }
/**
* Set an option to a string value in a section.
@@ -184,8 +196,14 @@
final String v = getValueChoice(section, option,
Arrays.asList("YES", "NO"));
if (v == null) {
+ Set<String> sources = sectionSources.get(section);
+ if (sources == null) {
+ logger.info("No sources for section '{}'", section);
+ } else {
+ logger.info("Sources for section '{}': {}", section, sources);
+ }
throw new ParsingError(String.format(
- "Failure in configuration section %s: option %s not found",
+ "Failure in configuration section '%s': option '%s' not
found",
section, option));
}
if (v.equals("YES")) {
@@ -197,6 +215,7 @@
throw new ParsingError(
"Configuration error: value not recognized as YES or NO");
}
+
/**
* Tests if we have a value for a particular option.
@@ -253,6 +272,11 @@
setValueString(current_section, option, value);
} else if ((m=section.matcher(line)).matches()) {
current_section = m.group(1).trim();
+ if (sectionSources.containsKey(current_section)) {
+ sectionSources.get(current_section).add(filename);
+ } else {
+ sectionSources.put(current_section, new
HashSet<String>(Collections.singleton(filename)));
+ }
} else if (whitspace.matcher(line).matches()) {
// whitespace is ok
} else {
Modified: gnunet-java/src/org/gnunet/util/Program.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Program.java 2012-02-23 19:21:56 UTC
(rev 19995)
+++ gnunet-java/src/org/gnunet/util/Program.java 2012-02-23 20:33:22 UTC
(rev 19996)
@@ -50,6 +50,7 @@
protected final String[] unprocessedArgs;
private Parser optParser;
+ private final String[] args;
/**
@@ -60,13 +61,34 @@
* @param args
*/
public Program(String[] args) {
+ this.args = args;
optParser = new Parser(this);
unprocessedArgs = optParser.parse(args);
org.apache.log4j.Logger rootLogger = LogManager.getRootLogger();
+
+ // category: 2 levels
+ //
+ Layout layout = new PatternLayout("%d{dd MMM yyyy HH:mm:ss-SSS} %c{2}
%p: %m%n");
+
+ if (logFile == null) {
+ rootLogger.addAppender(new ConsoleAppender(layout,
ConsoleAppender.SYSTEM_OUT));
+ } else {
+ Appender appender = null;
+ try {
+ appender = new FileAppender(layout, logFile);
+ } catch (IOException e) {
+ logger.warn("could not open log file {}", logFile);
+ }
+ if (appender!= null) {
+ rootLogger.removeAllAppenders();
+ rootLogger.addAppender(appender);
+ }
+ }
+
if (logLevel == null) {
- // do nothing
+ rootLogger.setLevel(Level.INFO);
} else if (logLevel.equalsIgnoreCase("debug")) {
rootLogger.setLevel(Level.DEBUG);
} else if (logLevel.equalsIgnoreCase("info")) {
@@ -82,20 +104,8 @@
logger.info("unknown log level '{}'; defaulting to INFO",
logLevel);
}
- if (logFile != null) {
- Layout layout = new PatternLayout("%-5p %c:\n%m%n");
- Appender appender = null;
- try {
- appender = new FileAppender(layout, logFile);
- } catch (IOException e) {
- logger.warn("could not open log file {}", logFile);
- }
- if (appender!= null) {
- rootLogger.removeAllAppenders();
- rootLogger.addAppender(appender);
- }
- }
+
cfg.loadDefaults();
if (cfgFileName != null) {
@@ -127,6 +137,9 @@
} else {
Scheduler.run(new Scheduler.Task() {
public void run(Scheduler.RunContext c) {
+ // kind of horrible hack: because of the default
constructor, default member values are overwritten
+ // in their constructor
+ optParser.parse(args);
Program.this.run();
}
});
Modified: gnunet-java/src/org/gnunet/util/Resolver.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Resolver.java 2012-02-23 19:21:56 UTC
(rev 19995)
+++ gnunet-java/src/org/gnunet/util/Resolver.java 2012-02-23 20:33:22 UTC
(rev 19996)
@@ -3,6 +3,7 @@
import org.gnunet.construct.*;
import org.gnunet.exceptions.InterfaceViolationException;
+import org.gnunet.exceptions.InternalLogicError;
import org.gnunet.exceptions.MessageFormatException;
import org.gnunet.util.getopt.Option;
import org.gnunet.util.getopt.OptionAction;
@@ -14,6 +15,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
+import java.util.LinkedList;
public class Resolver {
private static final Logger logger = LoggerFactory
@@ -162,8 +164,6 @@
}
-
-
private void connect(Configuration cfg) {
if (client != null) {
throw new InterfaceViolationException("connectStep called twice");
@@ -197,63 +197,7 @@
}
- public void resolveReverse(InetAddress inAddr, RelativeTime timeout,
HostnameCallback cb) {
- lazyConnect();
-
- byte[] addr = inAddr.getAddress();
- final GetMessage gmsg = new GetMessage();
- gmsg.header = new MessageHeader();
- gmsg.header.messageType = GetMessage.MSG_ID;
- gmsg.direction = GetMessage.DIRECTION_GET_NAME;
- if (addr.length == 4) {
- gmsg.domain = GetMessage.AF_INET;
- } else if (addr.length == 16) {
- gmsg.domain = GetMessage.AF_INET6;
- } else {
- throw new RuntimeException("invalid InetAddress");
- }
-
- NumericAddress nAddr = new NumericAddress();
- nAddr.addr = Arrays.copyOf(addr, 16);
-
- gmsg.addr = nAddr;
-
- gmsg.header.messageSize = Construct.getSize(gmsg);
-
-
- System.out.println("msgsize: " + gmsg.header.messageSize);
- System.out.println("really: " + (Construct.toBinary(gmsg).length));
-
-
- client.notifyTransmitReady(timeout, true, new MessageTransmitter() {
- @Override
- public void transmit(Client.MessageSink sink) {
- sink.send(gmsg);
- System.out.println("transmitting");
-
- client.receive(new MessageReceiver() {
- @Override
- public void process(Message msg) {
- System.out.println("receiving");
- ResolverResponse resp = (ResolverResponse) msg;
- }
-
- @Override
- public void handleTimeout() {
- }
- }, RelativeTime.FOREVER);
-
- }
-
-
- @Override
- public void handleTimeout() {
- }
- });
-
- }
-
private InetAddress getInet4Localhost() {
try {
return InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
@@ -264,35 +208,93 @@
private InetAddress getInet6Localhost() {
try {
- return InetAddress.getByAddress(new
byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1});
+ return InetAddress.getByAddress(new byte[]{0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1});
} catch (UnknownHostException e) {
throw new RuntimeException();
}
}
+ public class ResolveHandle {
+ private String hostname;
+ private AbsoluteTime deadline;
+ private AddressCallback cb;
+ private boolean finished = false;
+ private boolean canceled = false;
+ private Client.TransmitHandle transmitTask = null;
+ private Client.ReceiveHandle receiveTask = null;
- public void resolveHostname(String hostname, RelativeTime timeout, final
AddressCallback cb) {
+ public void cancel() {
+ if (finished) {
+ throw new InterfaceViolationException("Resolve already
finished");
+ }
+ if (canceled) {
+ throw new InterfaceViolationException("ResolveHandle canceled
twice");
+ }
+ if (queuedRequests.contains(this)) {
+ queuedRequests.remove(this);
+ } else {
+ if (receiveTask != null) {
+ receiveTask.cancel();
+ }
+ if (transmitTask != null) {
+ transmitTask.cancel();
+ }
+ }
+ canceled = true;
+ }
+ }
+
+ private LinkedList<ResolveHandle> queuedRequests = new
LinkedList<ResolveHandle>();
+
+ private boolean resolveActive = false;
+
+ public ResolveHandle resolveHostname(String hostname, RelativeTime
timeout, final AddressCallback cb) {
+ ResolveHandle rh = new ResolveHandle();
+ rh.hostname = hostname;
+ rh.deadline = timeout.toAbsolute();
+ rh.cb = cb;
// try if hostname is numeric IP or loopback
if (hostname.equalsIgnoreCase("localhost")) {
cb.onAddress(getInet6Localhost());
cb.onAddress(getInet4Localhost());
+ rh.finished = true;
cb.onFinished();
- return;
+ return rh;
}
if (hostname.equalsIgnoreCase("ip6-localhost")) {
cb.onAddress(getInet6Localhost());
+ rh.finished = true;
cb.onFinished();
- return;
+ return rh;
}
- InetAddress inetAddr = getInetAddressFromString(hostname);
+ InetAddress inetAddr = getInetAddressFromString(rh.hostname);
if (inetAddr != null) {
cb.onAddress(inetAddr);
+ rh.finished = true;
cb.onFinished();
- return;
+ return rh;
}
+ queuedRequests.addLast(rh);
+ handleNextRequest();
+ return rh;
+ }
+ private void handleNextRequest() {
+ if (!resolveActive && !queuedRequests.isEmpty()) {
+ ResolveHandle rh = queuedRequests.pollFirst();
+ handleRequest(rh);
+ }
+ }
+
+ private void handleRequest(final ResolveHandle rh) {
+ if (resolveActive) {
+ throw new InternalLogicError("resolveActive but new resolve
started");
+ }
+
+ resolveActive = true;
+
lazyConnect();
final GetMessage req = new GetMessage();
@@ -302,32 +304,32 @@
req.domain = GetMessage.AF_UNSPEC;
TextualAddress textAddr = new TextualAddress();
- textAddr.addr = hostname;
+ textAddr.addr = rh.hostname;
req.addr = textAddr;
req.header.messageSize = Construct.getSize(req);
- final AbsoluteTime deadline = timeout.toAbsolute();
+ final AbsoluteTime deadline = rh.deadline;
- logger.debug("resolver timeout:::::: " + timeout);
-
-
+
logger.debug("deadline is " + deadline + " | now is " +
AbsoluteTime.now());
logger.debug("remaining is " + deadline.getRemaining());
- client.notifyTransmitReady(
+ rh.transmitTask = client.notifyTransmitReady(
deadline.getRemaining(), true,
new MessageTransmitter() {
@Override
public void transmit(Client.MessageSink sink) {
sink.send(req);
+ rh.transmitTask = null;
logger.debug("recv in notifyTransmitReady cb");
- client.receive(new MessageReceiver() {
+ rh.receiveTask =
client.receive(deadline.getRemaining(), new MessageReceiver() {
@Override
public void process(Message msg) {
+ rh.receiveTask = null;
ResolverResponse gmsg = (ResolverResponse) msg;
if (gmsg.responseBody != null) {
try {
@@ -339,36 +341,44 @@
throw new
MessageFormatException("malformed address message");
}
- cb.onAddress(in_addr);
- client.receive(this,
deadline.getRemaining());
+ rh.cb.onAddress(in_addr);
+ rh.receiveTask =
client.receive(deadline.getRemaining(), this);
} catch (UnknownHostException e) {
throw new
MessageFormatException("malformed address");
}
} else {
- cb.onFinished();
+ resolveActive = false;
+ rh.cb.onFinished();
+ handleNextRequest();
}
}
@Override
public void handleTimeout() {
logger.debug("timeout in recv");
- cb.onTimeout();
+ onTimeout(rh);
}
- }, deadline.getRemaining());
+ });
}
@Override
public void handleTimeout() {
logger.debug("timeout in notifyTransmitReady");
- cb.onTimeout();
+ onTimeout(rh);
}
});
+ }
+
+
+ private void onTimeout(ResolveHandle h) {
+ resolveActive = false;
+ h.cb.onTimeout();
+ handleNextRequest();
}
-
public static Resolver getInstance() {
if (singletonInstance == null) {
singletonInstance = new Resolver();
@@ -377,6 +387,20 @@
}
+ public static String ipToString(InetAddress addr) {
+ byte[] a = addr.getAddress();
+ if (a.length == 4) {
+ return addr.getHostAddress();
+ } else if (a.length == 16) {
+ String s = addr.getHostAddress();
+ // replace the first group of zeroes (not the longest) with ::
+ return s.replaceFirst("[:]?0[:](0[:])+0?", "::");
+ } else {
+ throw new RuntimeException("unknown InetAddress format");
+ }
+ }
+
+
public static void main(final String[] argv) {
new Program(argv) {
@Option(shortname = "r", longname = "reverse",
@@ -394,38 +418,39 @@
}
public void resolve() {
- for (String s : unprocessedArgs) {
- System.out.println(s);
- }
-
final RelativeTime timeout = RelativeTime.SECOND;
if (unprocessedArgs.length == 0) {
- System.out.println("no hostnames given");
+ logger.warn("no hostname(s) given");
} else {
- System.out.println("resolving hostname '" +
unprocessedArgs[0] + "'");
+ logger.info("resolving hostname '" + unprocessedArgs[0] +
"'");
Resolver.getInstance().resolveHostname(unprocessedArgs[0],
timeout, new AddressCallback() {
int next = 1;
@Override
public void onAddress(InetAddress addr) {
- System.out.println(addr);
+ System.out.println(ipToString(addr));
}
@Override
public void onFinished() {
- System.out.println("done.");
+ logger.info("resolve finished");
+ next();
+ }
+
+ @Override
+ public void onTimeout() {
+ logger.warn("resolve timed out");
+ next();
+
+ }
+ public void next() {
if (unprocessedArgs.length > next) {
- System.out.println("resolving hostname '" +
unprocessedArgs[next] + "'");
+ logger.info("resolving hostname '" +
unprocessedArgs[next] + "'");
Resolver.getInstance().resolveHostname(unprocessedArgs[next], timeout, this);
next++;
}
}
-
- @Override
- public void onTimeout() {
- System.out.println("timed out");
- }
});
}
Modified: gnunet-java/src/org/gnunet/util/Scheduler.java
===================================================================
--- gnunet-java/src/org/gnunet/util/Scheduler.java 2012-02-23 19:21:56 UTC
(rev 19995)
+++ gnunet-java/src/org/gnunet/util/Scheduler.java 2012-02-23 20:33:22 UTC
(rev 19996)
@@ -131,7 +131,7 @@
&& (cs == null || cs.isEmpty());
if (deadline.isForever() && selectEmpty) {
- throw new InterfaceViolationException("unschedulable task
created");
+ logger.debug("unschedulable keep-alive task created");
}
if (timeout.getMilliseconds() == 0 && !selectEmpty) {
Added: gnunet-java/statistics
===================================================================
--- gnunet-java/statistics (rev 0)
+++ gnunet-java/statistics 2012-02-23 20:33:22 UTC (rev 19996)
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+DIR=`dirname $0`
+
+java -ea -cp "$DIR/bin/:$DIR/lib/*" org.gnunet.statistics.Statistics "$@"
Property changes on: gnunet-java/statistics
___________________________________________________________________
Added: svn:executable
+ *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19996 - in gnunet-java: . .idea src src/org/gnunet/construct src/org/gnunet/construct/parsers src/org/gnunet/nse src/org/gnunet/statistics src/org/gnunet/util,
gnunet <=