merge of '6c2ef00502207c28f02c90cef00b19d75f09d9a4'

and 'de35fdcdc8943537c71571c5c9d8320a24768cdf'
This commit is contained in:
walking
2009-11-18 15:05:14 +00:00
8 changed files with 127 additions and 42 deletions

View File

@ -89,6 +89,24 @@
<!-- jar again to get the latest messages_*.class files -->
<jar destfile="./build/routerconsole.jar" basedir="./build/obj" includes="**/*.class" update="true" />
</target>
<target name="poupdate" depends="compile">
<ant target="war" />
<!-- Update the messages_*.po files.
We need to supply the bat file for windows, and then change the fail property to true -->
<exec executable="sh" osfamily="unix" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
<exec executable="sh" osfamily="mac" failifexecutionfails="true" >
<arg value="./bundle-messages.sh" />
<arg value="-p" />
</exec>
<exec executable="cmd" osfamily="windows" failifexecutionfails="true" >
<arg value="/c" />
<arg value="bundle-messages.bat" />
<arg value="-p" />
</exec>
</target>
<target name="war" depends="precompilejsp">
<!-- Don't include the css in the war, the main build.xml will copy it to docs/themes/console/ -->
<war destfile="build/routerconsole.war" webxml="../jsp/web-out.xml"

View File

@ -2,12 +2,22 @@
# Update messages_xx.po and messages_xx.class files,
# from both java and jsp sources.
# Requires installed programs xgettext, msgfmt, msgmerge, and find.
#
# usage:
# bundle-messages.sh (generates the resource bundle from the .po file)
# bundle-messages.sh -p (updates the .po file from the source tags, then generates the resource bundle)
#
# zzz - public domain
#
CLASS=net.i2p.router.web.messages
TMPFILE=build/javafiles.txt
export TZ=UTC
if [ "$1" = "-p" ]
then
POUPDATE=1
fi
#
# generate strings/Countries.java from ../../../installer/resources/countries.txt
#
@ -37,8 +47,12 @@ do
LG=${i#../locale/messages_}
LG=${LG%.po}
# make list of java files newer than the .po file
find $JPATHS -name *.java -newer $i > $TMPFILE
if [ "$POUPDATE" = "1" ]
then
# make list of java files newer than the .po file
find $JPATHS -name *.java -newer $i > $TMPFILE
fi
if [ -s build/obj/net/i2p/router/web/messages_$LG.class -a \
build/obj/net/i2p/router/web/messages_$LG.class -nt $i -a \
! -s $TMPFILE ]
@ -46,42 +60,46 @@ do
continue
fi
echo "Generating ${CLASS}_$LG ResourceBundle..."
if [ "$POUPDATE" = "1" ]
then
echo "Updating the $i file from the tags..."
# extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms:
# _("foo")
# _x("foo")
# intl._("foo")
# intl.title("foo")
# handler._("foo")
# formhandler._("foo")
# net.i2p.router.web.Messages.getString("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=handler._ --keyword=formhandler._ \
--keyword=net.i2p.router.web.Messages.getString \
-o ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - xgettext failed, not updating translations'
rm -f ${i}t
break
fi
msgmerge -U --backup=none $i ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - msgmerge failed, not updating translations'
rm -f ${i}t
break
fi
rm -f ${i}t
# so we don't do this again
touch $i
fi
# extract strings from java and jsp files, and update messages.po files
# translate calls must be one of the forms:
# _("foo")
# _x("foo")
# intl._("foo")
# intl.title("foo")
# handler._("foo")
# formhandler._("foo")
# net.i2p.router.web.Messages.getString("foo")
# In a jsp, you must use a helper or handler that has the context set.
# To start a new translation, copy the header from an old translation to the new .po file,
# then ant distclean updater.
find $JPATHS -name *.java > $TMPFILE
xgettext -f $TMPFILE -F -L java --from-code=UTF-8 \
--keyword=_ --keyword=_x --keyword=intl._ --keyword=intl.title \
--keyword=handler._ --keyword=formhandler._ \
--keyword=net.i2p.router.web.Messages.getString \
-o ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - xgettext failed, not updating translations'
rm -f ${i}t
break
fi
msgmerge -U --backup=none $i ${i}t
if [ $? -ne 0 ]
then
echo 'Warning - msgmerge failed, not updating translations'
rm -f ${i}t
break
fi
rm -f ${i}t
# so we don't do this again
touch $i
echo "Generating ${CLASS}_$LG ResourceBundle..."
# convert to class files in build/obj
msgfmt --java -r $CLASS -l $LG -d build/obj $i

View File

@ -32,6 +32,7 @@
<echo message=" pkgWithDesktopgui: distclean then package everything up with the desktopgui" />
<echo message=" distWithDesktopgui: pkgWithDesktopgui and javadoc" />
<echo message=" distcleanWithDesktopgui: clean up all derived files (including desktopgui files)" />
<echo message=" poupdate: update the .po files for translators" />
</target>
<target name="debianhowto">
<echo message="To build debian packages, you must run dpkg-buildpackage as root in the source directory. It will then run ant for you. dpkg-buildpackage is found in the 'dpkg-dev' package. Also it should work fine to use the 'fakeroot' package with dpkg-buildpackage, if you don't want to run as root. Please read 'man dpkg-buildpackage' before building any packages yourself." />
@ -138,6 +139,9 @@
<copy file="installer/lib/jbigi/jbigi.jar" todir="build" />
<copy file="apps/addressbook/dist/addressbook.war" todir="build/" />
</target>
<target name="poupdate">
<ant dir="apps/routerconsole/java/" target="poupdate" />
</target>
<target name="javadoc">
<mkdir dir="./build" />
<mkdir dir="./build/javadoc" />

View File

@ -1,3 +1,13 @@
2009-11-18 zzz
* Build: Don't update the po files by default, add new
target "poupdate" to do that.
* Netdb:
- Floodfill rework part 3 of N: Send closest-to-the-key
in DSRM replies
- Adjust criteria for following DSRM
- Note failed floods in the profile
- Reduce max flood
2009-11-16 zzz
* addressbook: Move class to net.i2p.addressbook
* build: Take two test scripts out of the installer

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 18;
public final static long BUILD = 19;
/** for example "-test" */
public final static String EXTRA = "";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;

View File

@ -99,7 +99,7 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
}
}
private static final int MAX_TO_FLOOD = 9;
private static final int MAX_TO_FLOOD = 7;
/**
* Send to a subset of all floodfill peers.
@ -139,6 +139,10 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
m.setPriority(FLOOD_PRIORITY);
m.setTarget(target);
m.setExpiration(_context.clock().now()+FLOOD_TIMEOUT);
// note send failure but don't give credit on success
// might need to change this
Job floodFail = new FloodFailedJob(_context, peer);
m.setOnFailedSendJob(floodFail);
_context.commSystem().processMessage(m);
flooded++;
if (_log.shouldLog(Log.INFO))
@ -149,6 +153,20 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
_log.info("Flooded the data to " + flooded + " of " + peers.size() + " peers");
}
/** note in the profile that the store failed */
private static class FloodFailedJob extends JobImpl {
private Hash _peer;
public FloodFailedJob(RouterContext ctx, Hash peer) {
super(ctx);
_peer = peer;
}
public String getName() { return "Flood failed"; }
public void runJob() {
getContext().profileManager().dbStoreFailed(_peer);
}
}
private static final int FLOOD_PRIORITY = 200;
private static final int FLOOD_TIMEOUT = 30*1000;

View File

@ -299,4 +299,16 @@ class FloodfillPeerSelector extends PeerSelector {
}
public int size() { return _matches; }
}
/**
* Floodfill peers only. Used only by HandleDatabaseLookupMessageJob to populate the DSRM.
*
* @param key the original key (NOT the routing key)
* @return List of Hash for the peers selected, ordered
*/
@Override
public List<Hash> selectNearest(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet kbuckets) {
Hash rkey = _context.routingKeyGenerator().getRoutingKey(key);
return selectFloodfillParticipants(rkey, maxNumRouters, peersToIgnore, kbuckets);
}
}

View File

@ -1,6 +1,7 @@
package net.i2p.router.networkdb.kademlia;
import net.i2p.data.Hash;
import net.i2p.data.RouterInfo;
import net.i2p.data.i2np.DatabaseSearchReplyMessage;
import net.i2p.router.JobImpl;
import net.i2p.router.RouterContext;
@ -10,7 +11,7 @@ import net.i2p.util.Log;
* Ask the peer who sent us the DSRM for the RouterInfos.
*
* If we have the routerInfo already, try to refetch it from that router itself,
* if we aren't already connected to that router,
* (if the info is old or we don't think it is floodfill)
* which will help us establish that router as a good floodfill and speed our
* integration into the network.
*
@ -32,9 +33,13 @@ class SingleLookupJob extends JobImpl {
Hash peer = _dsrm.getReply(i);
if (peer.equals(getContext().routerHash())) // us
continue;
if (getContext().netDb().lookupRouterInfoLocally(peer) == null)
if (peer.equals(from)) // wtf
continue;
RouterInfo ri = getContext().netDb().lookupRouterInfoLocally(peer);
if (ri == null)
getContext().jobQueue().addJob(new SingleSearchJob(getContext(), peer, from));
else if (!getContext().commSystem().isEstablished(peer))
else if (ri.getPublished() < getContext().clock().now() - 60*60*1000 ||
!FloodfillNetworkDatabaseFacade.isFloodfill(ri))
getContext().jobQueue().addJob(new SingleSearchJob(getContext(), peer, peer));
}
}