From: <ju...@us...> - 2006-10-26 16:43:01
|
Revision: 3529 http://svn.sourceforge.net/smartfrog/?rev=3529&view=rev Author: julgui Date: 2006-10-26 09:42:26 -0700 (Thu, 26 Oct 2006) Log Message: ----------- javadoc fixes. Modified Paths: -------------- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisListener.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/ProviderInstance.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/GlobalRegisterImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalListeners.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalProviders.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalRegisterImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/ActiveTimeQueue.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/SetMap.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/SelfConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/HeartbeatProtocolAdapter.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/ping/PingProtocolImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/timed/TimedProtocolImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/CandidateImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/LeaderMgr.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/mainconsole/TestConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/node/TestConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/NodeIdSet.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisListener.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisListener.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisListener.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -111,7 +111,7 @@ * of the AnubisValue class. * * @param i - * @return + * @return AnubisValue */ public AnubisValue createValue(ProviderInstance i) { return new AnubisValue(i); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -87,7 +87,7 @@ /** * setTime is introduced to allow for the SubProcess interface. Remote * interfaces need to be re-done - this is a temporary fix. - * @param time + * @param value */ protected void setValueObj(ValueData value) { this.value = value; } protected void setInstance(String instance) { this.instance = instance; } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/ProviderInstance.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/ProviderInstance.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/ProviderInstance.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -45,7 +45,7 @@ /** * Create a provider proxy that matches this instance - * @return + * @return proxy provider */ public ProviderProxy proxy() { return new ProviderProxy(name, node); @@ -63,7 +63,7 @@ * data). * * @param obj - * @return + * @return boolean */ public boolean equals(Object obj) { if( obj instanceof ProviderInstance ) @@ -78,7 +78,7 @@ * classes and providerInstance classes in a container will work, but is * poor style - it gets confusing. * - * @return + * @return hascode */ public int hashCode() { return super.hashCode(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/GlobalRegisterImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/GlobalRegisterImpl.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/GlobalRegisterImpl.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -78,7 +78,7 @@ /** * Constructor - sets the local * @param id - * @param l + * @param locator */ public GlobalRegisterImpl(Identity id, Locator locator) { this.me = id.id; @@ -385,7 +385,7 @@ /** * List out the contents of the register by node. - * @return + * @return String */ public synchronized String toString() { if( !active ) Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalListeners.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalListeners.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalListeners.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -227,8 +227,6 @@ /** * deregister a listener. - * - * @param name * @param listener */ public synchronized void deregister(AnubisListener listener) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalProviders.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalProviders.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalProviders.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -88,7 +88,7 @@ * Constructor * * @param l - * @param g + * @param id */ public LocalProviders(Locator l, Integer id) { locator = l; @@ -103,8 +103,9 @@ * * FIX ME: does not check for uniqueness in the partition. * - * @param name - unique name associated with the provider - * @param provider - the provider interface + * @param provider - the provider interface + * @param value + * @param time */ public synchronized void register(AnubisProvider provider, ValueData value, long time) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalRegisterImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalRegisterImpl.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/registers/LocalRegisterImpl.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -284,8 +284,6 @@ * the listeners are responsible for contacting this * local registry to get provider info. * @param provider - * @param name - * @return */ public void registerProvider(AnubisProvider provider) { requests.put(new UserProviderRequest(UserProviderRequest.Register, @@ -302,8 +300,6 @@ * register. * deregister with local register. * @param provider - * @param name - * @return */ public void deregisterProvider(AnubisProvider provider) { requests.put(new UserProviderRequest(UserProviderRequest.Deregister, @@ -328,7 +324,6 @@ /** * @param listener - * @return */ public void registerListener(AnubisListener listener) { requests.put(new UserListenerRequest(UserListenerRequest.Register, listener)); @@ -342,8 +337,6 @@ * and there are no more. * The global only has pending listeners registered. * @param listener - * @param name - * @return */ public void deregisterListener(AnubisListener listener) { requests.put(new UserListenerRequest(UserListenerRequest.Deregister, listener)); @@ -398,8 +391,8 @@ * 3) register all providers and listeners again * Note: we are being dumb and pessimistic here - always recover all * registrations - could be more clever. - * - * @param g + * @param leader + * @param timeStamp */ public synchronized void stable(int leader, long timeStamp) { stable = true; Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/ActiveTimeQueue.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/ActiveTimeQueue.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/ActiveTimeQueue.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -140,7 +140,7 @@ * * @param element * @param time - * @return + * @return boolean */ public boolean add(TimeQueueElement element, long time) { synchronized( queue ) { @@ -159,7 +159,7 @@ * now? * * @param element - * @return + * @return boolean */ public boolean remove(TimeQueueElement element) { synchronized( queue ) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/SetMap.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/SetMap.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/util/SetMap.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -66,7 +66,7 @@ /** * indicates if the map is empty * - * @return + * @return boolean */ public boolean isEmpty() { return map.isEmpty(); } @@ -89,7 +89,7 @@ * returns a set view of the entries in the map. That is a set of * objects of the type Map.Entry. * - * @return + * @return Set */ public Set entrySet() { return map.entrySet(); } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -71,7 +71,7 @@ * * @param id - the identity of this node * @param cs - the connection set - * @param con - the heartbeat connection (used to get details of the connection) + * @param can - the heartbeat connection (used to get details of the connection) */ public MessageConnection(Identity id, ConnectionSet cs, HeartbeatProtocol hbp, Candidate can) { super(hbp, can); @@ -117,7 +117,7 @@ * General deliver method - any messaage received by the transport will * be delivered using this method. The message will be a valid TimedMsg! * - * @param msg - the message + * @param bytes - the message */ public void deliver(byte[] bytes) { @@ -288,7 +288,7 @@ /** * - * @param msg + * @param tm */ public void sendMsg(TimedMsg tm) { if (tm == null) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/SelfConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/SelfConnection.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/SelfConnection.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -70,13 +70,13 @@ /** * HeartbeatProtocol interface - * @param m + * @param h */ public boolean receiveHeartbeat(Heartbeat h) { return true; } /** * Candidate interface - redirect to CandidateImpl - * @return + * @return Indentity */ public Identity getId() { return getSender(); } public Identity getVote() { return candidate.getVote(); } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -80,7 +80,7 @@ * Create a new MessageConnectionImpl in response to a connection request. This * method is called by the ConnectionServer base class. * - * @param so + * @param channel * public void createConnection(Socket so) { MessageConnectionImpl impl = new MessageConnectionImpl(me, so, this, Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -123,7 +123,7 @@ * connection. But the method of the base class MulticastComms to send is * sendObject(). * - * @param msg + * @param obj */ public void sendObject(Object obj) { return; } public void sendHeartbeat(HeartbeatMsg msg) { @@ -139,7 +139,7 @@ * This will be called from the connection set - ignoring is used in a * critical section in deliverObject() that uses connectionSet as its * monitor. - * @param ignoring + * @param ignoringUpdate */ public void setIgnoring(View ignoringUpdate){ synchronized(ingnoringMonitor) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -238,7 +238,7 @@ * on the socketChannel. If that first write was enough to send the whole packet then SENDING_DONE is returned * otherwise SENDING_PENDING is returned. The registered SendingListener will be called when all the data has gone * - * @param objectToSend the object to be serialized + * @param bytesToSend the object to be serialized * @param listener the object to call back when the whole object has been successfully sent on the socketChannel * @return sending error code from SENDING_DONE, SENDING_PENDING or SENDING_REFUSED */ Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/HeartbeatProtocolAdapter.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/HeartbeatProtocolAdapter.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/HeartbeatProtocolAdapter.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -131,7 +131,7 @@ /** * Candidate interface - * @return + * @return Identity */ public Identity getId() { return candidate.getId(); } public Identity getVote() { return candidate.getVote(); } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/ping/PingProtocolImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/ping/PingProtocolImpl.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/ping/PingProtocolImpl.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -111,7 +111,7 @@ * and the timebound. * * @param timenow current time - * @param timeout expiration period + * @param timebound expiration period * @return true if expried, false if not */ public boolean isNotTimely(long timenow, long timebound) { @@ -153,7 +153,7 @@ * information counts. * * @param hb - heartbeat message - * @return + * @return boolean */ public boolean receiveHeartbeat(Heartbeat hb) { @@ -209,7 +209,7 @@ /** * Timed interface - * @return + * @return long */ public long getTime() { return time; @@ -221,7 +221,7 @@ /** * Sender interface - * @return + * @return identity */ public Identity getSender() { return sender; Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/timed/TimedProtocolImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/timed/TimedProtocolImpl.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/heartbeat/timed/TimedProtocolImpl.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -66,7 +66,7 @@ * and the timebound. * * @param timenow current time - * @param timeout expiration period + * @param timebound expiration period * @return true if expried, false if not */ public boolean isNotTimely(long timenow, long timebound) { @@ -108,7 +108,7 @@ * information counts. * * @param hb - heartbeat message - * @return + * @return boolean false if terminated or failed */ public boolean receiveHeartbeat(Heartbeat hb) { @@ -164,14 +164,14 @@ /** * Timed interface - * @return + * @return time */ public long getTime() { return time; } public void setTime(long t) { time = t; } /** * Sender interface - * @return + * @return identity */ public Identity getSender() { return sender; } public ConnectionAddress getSenderAddress() { return address; } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/CandidateImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/CandidateImpl.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/CandidateImpl.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -44,7 +44,7 @@ /** * Candidate interface - * @return + * @return Identity */ public Identity getId() { return me;} public Identity getVote() { return vote;} Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/LeaderMgr.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/LeaderMgr.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/leader/LeaderMgr.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -42,7 +42,7 @@ * Returns the current leader - assumes there has been an election. * The local candidate always votes for the winner of the local * election. So return the local candidates vote - * @return + * @return Identity */ public Identity getLeader() { return localCandidate.getVote(); @@ -60,7 +60,7 @@ * node voted for are both in the partition. * * @param v - * @return + * @return Candidate */ private synchronized Candidate election(View v) { @@ -130,7 +130,7 @@ * the view. * * @param v - * @return + * @return Identity */ public synchronized Identity electLeader(View v) { return (v.isStable() ? stableElection(v) : unstableElection(v)); @@ -141,7 +141,7 @@ * Perform the stable election (most votes wins - highest id as tie-breaker) * * @param v - * @return + * @return Identity */ private Identity stableElection(View v) { localCandidate.setVote(election(v)); @@ -154,7 +154,7 @@ * otherwise local candidate) * * @param v - * @return + * @return Identity */ private Identity unstableElection(View v) { if( !v.contains(localCandidate.getVote()) ) @@ -172,7 +172,7 @@ * guarantee on accuracy, but it can be used as a guide. * * @param v - * @return + * @return Identity */ public synchronized Identity predictLeader(View v) { return election(v).getId(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -362,8 +362,8 @@ /** * gets the connection in the specified possition of the connection set. - * @param i - * @return + * @param id + * @return connection */ public synchronized Connection getConnection(Identity id) { return (Connection)connections.get( id ); @@ -842,7 +842,7 @@ /** * Returns an indication of * @param id - * @return + * @return boolean true if message link contains id */ public boolean wantsMsgLinkTo(Identity id) { return msgLinks.contains(id.id); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/mainconsole/TestConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/mainconsole/TestConnection.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/mainconsole/TestConnection.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -46,7 +46,7 @@ /** * Connection comms interface - * @param obj + * @param bytes */ public void deliver(byte[] bytes) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/node/TestConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/node/TestConnection.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/test/node/TestConnection.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -50,7 +50,7 @@ /** * Connection comms interface - * @param obj + * @param bytes */ public void deliver(byte[] bytes) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/NodeIdSet.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/NodeIdSet.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/NodeIdSet.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -300,7 +300,6 @@ /** * Return a new identical copy - * @param s BitSet * @return BitSet */ public Object clone(){ Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -87,6 +87,7 @@ * pattern of simply extending the super(byte[]) * sonstructor because it wants to retain the wire and * byte buffer for lazy unmarshalling later. + * @param wireForm * * @return long */ @@ -122,7 +123,7 @@ /** * NumberedView interface implementation - * @return + * @return view */ public View getView() { if( !viewUnmarshalled ) @@ -147,7 +148,7 @@ /** * Candidate interface - * @return + * @return identity */ public Identity getCandidate() { if( !candidateUnmarshalled ) @@ -161,7 +162,7 @@ /** * Message link requirements data field - * @return + * @return NodeIdSet */ public NodeIdSet getMsgLinks() { if( !msgLinksUnmarshalled ) @@ -174,7 +175,7 @@ /** * testInterface get and set - * @return + * @param address */ public void setTestInterface(ConnectionAddress address) { testInterface = address; @@ -228,8 +229,6 @@ /** * Write the message attributes to the - * - * @param wire byte[] */ protected void writeWireForm() throws WireFormException { super.writeWireForm(); @@ -269,7 +268,7 @@ * on demand. These attributes are not likely to be needed often - so we * only unmarshall them when we have to. * - * @param wireForm byte[] + * @param buf byte[] */ protected void readWireForm(ByteBuffer buf) throws IOException, WireFormException, ClassNotFoundException { super.readWireForm(buf); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -49,7 +49,8 @@ /** * Construct a ping heartbeat message * - * @param hb HeartbeatMsg + * @param identity + * @param address */ public PingHeartbeatMsg(Identity identity, ConnectionAddress address) { super(identity, address); @@ -103,8 +104,6 @@ /** * Write the message attributes to the - * - * @param wire byte[] */ protected void writeWireForm() throws WireFormException { super.writeWireForm(); @@ -114,7 +113,7 @@ /** * Read the attributes from the wire format. * - * @param wireForm byte[] + * @param buf byte[] */ protected void readWireForm(ByteBuffer buf) throws IOException, WireFormException, ClassNotFoundException { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -98,7 +98,7 @@ /** * Sender interface implemenation - * @return + * @return identity */ public Identity getSender() { return sender; } public ConnectionAddress getSenderAddress() { @@ -124,9 +124,10 @@ /** * Sets the timed message attributes to the wire form held in a * byte array - * - * @param wireForm byte[] - * @throws UnknownHostException + * @param buf + * @throws IOException + * @throws WireFormException + * @throws ClassNotFoundException */ protected void readWireForm(ByteBuffer buf) throws IOException, WireFormException, ClassNotFoundException { super.readWireForm(buf); @@ -138,7 +139,6 @@ * Writes the timed message attributes to wire form in the given byte * array * - * @param wireForm byte[] */ protected void writeWireForm() throws WireFormException { super.writeWireForm(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java 2006-10-26 16:02:11 UTC (rev 3528) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java 2006-10-26 16:42:26 UTC (rev 3529) @@ -95,7 +95,7 @@ /** * read wire message format * - * @param wire byte[] + * @param buf byte[] * @throws IOException * @throws WireFormException * @throws ClassNotFoundException @@ -121,7 +121,6 @@ * Writes the timed message attributes to wire form in the given byte * array * - * @param wireForm byte[] */ protected void writeWireForm() throws WireFormException { super.writeWireForm(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ju...@us...> - 2006-10-26 16:49:52
|
Revision: 3530 http://svn.sourceforge.net/smartfrog/?rev=3530&view=rev Author: julgui Date: 2006-10-26 09:49:40 -0700 (Thu, 26 Oct 2006) Log Message: ----------- javadoc fixes. Modified Paths: -------------- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/NameData.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/NameData.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/NameData.java 2006-10-26 16:42:26 UTC (rev 3529) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/names/NameData.java 2006-10-26 16:49:40 UTC (rev 3530) @@ -38,7 +38,7 @@ * particular name, but only one per node. * * @param obj - * @return + * @return boolean */ public boolean equals(Object obj) { if( obj instanceof NameData ) Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java 2006-10-26 16:42:26 UTC (rev 3529) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java 2006-10-26 16:49:40 UTC (rev 3530) @@ -350,7 +350,7 @@ * immediately inform the connectionSet to disconnect. * * @param impl - * @return + * @return boolean */ public boolean assignImpl(IOConnection impl) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java 2006-10-26 16:42:26 UTC (rev 3529) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java 2006-10-26 16:49:40 UTC (rev 3530) @@ -89,7 +89,6 @@ * byte buffer for lazy unmarshalling later. * @param wireForm * - * @return long */ public HeartbeatMsg(ByteBuffer wireForm) throws ClassNotFoundException, WireFormException, IOException { super(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java 2006-10-26 16:42:26 UTC (rev 3529) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java 2006-10-26 16:49:40 UTC (rev 3530) @@ -86,8 +86,6 @@ /** * Writes the timed message attributes to wire form in the given byte * array - * - * @param wireForm byte[] */ protected void writeWireForm() throws WireFormException { super.writeWireForm(); @@ -102,8 +100,10 @@ * Sets the timed message attributes to the wire form held in a * byte array * - * @param wireForm byte[] - * @throws UnknownHostException + * @param buf byte[] + * @throws IOException + * @throws WireFormException + * @throws ClassNotFoundException */ protected void readWireForm(ByteBuffer buf) throws IOException, WireFormException, ClassNotFoundException { super.readWireForm(buf); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2006-10-26 16:42:26 UTC (rev 3529) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2006-10-26 16:49:40 UTC (rev 3530) @@ -60,7 +60,6 @@ * the fromWire(wire) method, read attributes in the * readWireForm(wire) method. * - * @return long */ public TimedMsg(ByteBuffer wireForm) throws ClassNotFoundException, WireFormException, IOException { super(); @@ -91,7 +90,7 @@ /** * Timed interface - * @return + * @return long time */ public long getTime() { return time; } public void setTime(long t) { time = t; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2007-01-24 17:11:25
|
Revision: 3830 http://svn.sourceforge.net/smartfrog/?rev=3830&view=rev Author: steve_l Date: 2007-01-24 09:11:20 -0800 (Wed, 24 Jan 2007) Log Message: ----------- fix ambiguous opening sentences in the anubis javadocs. This stops cruise control from generating so many complaints. Modified Paths: -------------- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Epoch.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -30,6 +30,8 @@ /** + * Server of connections. + * * ConnectionServer is a socket listener server that receives connection * requests on a given address, accepts them and creates an endpoint * object to handle the connection. The endpoint is created using a @@ -42,6 +44,7 @@ private LogSF log = LogFactory.getLog(this.getClass().toString()); /** + * Default constructor is initually unusable. * Constructor - sets a null listening socket and a null connection * factory (i.e. an unusable server). */ @@ -68,6 +71,7 @@ /** + * * Constructor - creates a listening socket on the default ip address * returned for the given host name (should be this host), using the * given port. Initially the default connection factory is assumed. Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -34,7 +34,9 @@ /** * MulticastComms is an abstract class representing an end point - * for multicast communications. The endpoint is capable of + * for multicast communications. + * + * The endpoint is capable of * sending and receiving objects, transfered in packets as object streams. * Note that there is a limit to the size of an object when transfered as * an object stream. Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/locator/AnubisProvider.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -22,15 +22,13 @@ /** - * <p>Title: </p> - * <p>Description: This is an abstract base class for the provider object. The - * provider is defined by the user by extendeding this class and - * can then be registered with the locator. When a named provider - * registers the locator recognises its presence in the partition.</p> + * Abstract base class for the provider object. * - * <p>Copyright: Copyright (c) 2002</p> - * <p>Company: </p> - * @author unascribed + * This is an abstract base class for the provider object. The + * provider is defined by the user by extendeding this class and + * can then be registered with the locator. When a named provider + * registers the locator recognises its presence in the partition. + * * @version 1.0 */ Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -215,7 +215,9 @@ /** - * Closing is called by shutdwon(). shutdown is used to terminate the + * Close down the connection. + * + * Closing is called by {@link #shutdown()}. shutdown is used to terminate the * connection both here (from the "outside") and in the implementation * of ConnectionComms (from the "inside"). The connection closes itself * from the inside if there is some kind of error on the connection. Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -118,14 +118,16 @@ } /** - * Change of interface - connection users send objects or messages. sendObject() - * is not permitted because the only heartbeats can be sent on a heartbeat - * connection. But the method of the base class MulticastComms to send is + * Change of interface - connection users send objects or messages. + * sendObject(Object) is not permitted because the only heartbeats + * can be sent on a heartbeat connection. But the method of the base class + * MulticastComms to send is to take an arbitrary Object. * sendObject(). * * @param obj */ public void sendObject(Object obj) { return; } + public void sendHeartbeat(HeartbeatMsg msg) { try { super.sendObject(msg.toWire()); } catch (Exception ex) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -65,14 +65,12 @@ /** - * <p>Title: Anubis Detection Service</p> + * Anubis Detection Service. * - * <p>Description: - * * ConnectionSet is the heart of the protocol. This object maintains the * local view of the world as a set of connections that it recognises as * valid with other nodes. This connection set is the base information that - * the partition manager uses to determine a valid partition.</p> + * the partition manager uses to determine a valid partition. * * <p>Copyright: Copyright (c) 2002</p> * <p>Company: Hewlett-Packard Ltd.</p> Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Epoch.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Epoch.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Epoch.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -25,7 +25,8 @@ /** - * epoch. we need an epoch that monotonically increases to identify + * The Epoch. + * we need an epoch that monotonically increases to identify * incarnations of a partition manager. Previously we used a value * stored on stable storage, but then we wanted to be able to refresh * the storage with a blank image, so we chose time instead. Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -30,7 +30,8 @@ import org.smartfrog.services.anubis.partition.wire.WireSizes; /** - * Identity represents the identity of a parititon manager. The identity + * The identity of a partiton manager. + * Identity represents the identity of a partiton manager. The identity * is based on a magic number (to allow multiple instances in the same * network not to conflict), an integer id, and an epoch number to differentiate * incarnations of the same manager. Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -20,16 +20,8 @@ package org.smartfrog.services.anubis.partition.wire; /** - * Wire form conversion exceptions - * <p>Title: </p> + * Wire form conversion exceptions. * - * <p>Description: </p> - * - * <p>Copyright: Copyright (c) 2004</p> - * - * <p>Company: </p> - * - * @author not attributable * @version 1.0 */ public class WireFormException extends Exception { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java 2007-01-24 16:42:49 UTC (rev 3829) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java 2007-01-24 17:11:20 UTC (rev 3830) @@ -115,10 +115,11 @@ } /** - * top level writeWireForm() method. subtypes should implement this method + * Top level writeWireForm() method. + * subtypes should implement this method * to call their super.writeWireForm and then write their own attributes. * - * @throws WireFormException + * @throws WireFormException on trouble */ protected void writeWireForm() throws WireFormException { wireForm.putInt(0, getType()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <st...@us...> - 2007-05-14 13:02:00
|
Revision: 4130 http://svn.sourceforge.net/smartfrog/?rev=4130&view=rev Author: steve_l Date: 2007-05-14 06:01:59 -0700 (Mon, 14 May 2007) Log Message: ----------- SFOS-133: stop Cruise Control javadocs from complaining on anubis Modified Paths: -------------- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java 2007-05-14 12:56:00 UTC (rev 4129) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java 2007-05-14 13:01:59 UTC (rev 4130) @@ -127,10 +127,12 @@ /** + * Send an array of bytes. * The send function is synchronized to prevent multiple sends concurrent * sends (is this necessary??) Can not deadlock - multiple threads will take * turns to send, the receive loop (run) will block sends unless it is nested * in the deliverObject method, which is ok. + * @param bytes bytes to send */ public synchronized void sendObject(byte[] bytes) { try { @@ -151,6 +153,7 @@ /** * convert the input buffer to a string - for debug purposes. + * @return a stringified inBytes */ private String inputToString() { return new String(inBytes); @@ -158,7 +161,8 @@ /** - * returns an string representing the status of this thread + * Get the status of this thread. + * @return a string representing the status of this thread */ public String getThreadStatusString() { StringBuffer buffer = new StringBuffer(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-05-14 12:56:00 UTC (rev 4129) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-05-14 13:01:59 UTC (rev 4130) @@ -235,6 +235,7 @@ } /** + * Shut down the connection. * Terminate is used to instruct the implementation to shutdown the * connection. announceTerm is set to false so that the closing() * method does not call back to the messageConnection. Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2007-05-14 12:56:00 UTC (rev 4129) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2007-05-14 13:01:59 UTC (rev 4130) @@ -141,7 +141,7 @@ * This will be called from the connection set - ignoring is used in a * critical section in deliverObject() that uses connectionSet as its * monitor. - * @param ignoringUpdate + * @param ignoringUpdate a view */ public void setIgnoring(View ignoringUpdate){ synchronized(ingnoringMonitor) { Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java 2007-05-14 12:56:00 UTC (rev 4129) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/util/Identity.java 2007-05-14 13:01:59 UTC (rev 4130) @@ -70,7 +70,8 @@ } /** - * defines the equality relation for identities - used in containers + * Equality test: does not use epoch. + * Defines the equality relation for identities - used in containers * e.g. hash tables. - note: does not use epoch for equality!!!! * TWO IDENTITIES ARE EQUIVALENT IF THE HAVE THE SAME ID AND MAGIC NUMBER */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pau...@us...> - 2007-09-19 16:33:21
|
Revision: 5137 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=5137&view=rev Author: paul_murray Date: 2007-09-19 09:32:45 -0700 (Wed, 19 Sep 2007) Log Message: ----------- SFOS-447 Message authentication to protect the Anubis protocol from external interference Modified Paths: -------------- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/components.sf trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServerFactory.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/components.sf trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatCommsFactory.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServerFactory.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/components.sf trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/CloseMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingCloseMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java Added Paths: ----------- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/MACSecurityImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/NoSecurityImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurity.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurityException.java Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/multicasttransport/MulticastComms.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -53,7 +53,7 @@ * but any network will be capable of handling this size so its transfer * semantics are atomic (no fragmentation in the network). */ - static public final int MAX_SEG_SIZE = 1024; + static public final int MAX_SEG_SIZE = 1500; // Eathernet standard MTU private MulticastAddress groupAddress; private MulticastSocket sock; Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/components.sf =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/components.sf 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/components.sf 2007-09-19 16:32:45 UTC (rev 5137) @@ -76,6 +76,7 @@ connectionTransport extends NonBlockingConnectionTransport; heartbeatProtocolFactory extends TimedHeartbeatProtocol; leaderProtocolFactory extends MajorityLeaderProtocol; + security extends NoSecurity; preferred false; testable true; Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -19,14 +19,17 @@ */ package org.smartfrog.services.anubis.partition.comms; +import org.smartfrog.services.anubis.partition.wire.msg.TimedMsg; + public interface IOConnection { public void terminate(); public void silent(); public boolean connected(); - public void send(byte[] msg); +// public void send(byte[] msg); + public void send(TimedMsg msg); public void setIgnoring(boolean ignoring); } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/MessageConnection.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -119,6 +119,7 @@ * * @param bytes - the message */ + /******************************************************************* SECURITY public void deliver(byte[] bytes) { WireMsg msg = null; @@ -133,6 +134,8 @@ return; } + **************************************************************************/ + public void deliver(TimedMsg msg) { if( msg instanceof HeartbeatMsg ) { @@ -238,7 +241,8 @@ connectionImpl = null; try { - closingImpl.send( connectionSet.getHeartbeatMsg().toClose().toWire()); +// closingImpl.send( connectionSet.getHeartbeatMsg().toClose().toWire()); // SECURITY + closingImpl.send( connectionSet.getHeartbeatMsg().toClose()); } catch (Exception ex) { @@ -286,10 +290,10 @@ - /** + /**************************************************************************** + * SECURITY + * @param tm * - * @param tm - */ public void sendMsg(TimedMsg tm) { if (tm == null) { if (log.isErrorEnabled()) @@ -304,6 +308,7 @@ log.error(me + " failed to marshall timed message: " + tm + " for " + getSender() + " - not sent", ex); } } + * public void sendBytes(byte[] bytes) { @@ -313,7 +318,19 @@ new Exception()); return; } + + **********************************************************************/ + public void sendMsg(TimedMsg msg) { + + if (msg == null) { + if (log.isErrorEnabled()) + log.error(me + " sendBytes(WireMsg) called with null parameter ", + new Exception()); + return; + } + + synchronized (msgQ) { /** * If the connection has not been constructed, buffer the message. @@ -321,7 +338,8 @@ * deal with too many messages! */ if (connectionImpl == null) { - msgQ.addLast(bytes); +// msgQ.addLast(bytes); // SECURITY + msgQ.addLast(msg); return; } @@ -338,7 +356,8 @@ * If the connectionImpl exists and it is connected then just send on it. */ // System.out.println(me + " sending " + msg); - connectionImpl.send(bytes); +// connectionImpl.send(bytes); // SECURITY + connectionImpl.send(msg); } } @@ -368,7 +387,8 @@ connectionImpl.setIgnoring(ignoring); // indicate if it should ignore messages while( !msgQ.isEmpty() ) - connectionImpl.send((byte[])msgQ.removeFirst()); +// connectionImpl.send((byte[])msgQ.removeFirst()); // SECURITY + connectionImpl.send((TimedMsg)msgQ.removeFirst()); if(disconnectPending) connectionSet.disconnect( getSender() ); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -21,6 +21,7 @@ import org.smartfrog.services.anubis.partition.protocols.partitionmanager.ConnectionSet; import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; import org.smartfrog.services.anubis.partition.util.Identity; import org.smartfrog.services.anubis.partition.comms.MessageConnection; import java.io.IOException; @@ -32,7 +33,9 @@ private Identity me = null; private ConnectionSet connectionSet = null; private MessageConnection connection = null; - private byte[] heartbeat = null; +// private byte[] heartbeat = null; // SECURITY + private HeartbeatMsg heartbeat = null; + private WireSecurity wireSecurity = null; public BlockingConnectionInitiator(Identity id, MessageConnection con, @@ -43,7 +46,8 @@ me = id; connection = con; connectionSet = cset; - heartbeat = hb.toWire(); +// heartbeat = hb.toWire(); // SECURITY + heartbeat = hb; } /** @@ -54,7 +58,7 @@ public void run() { MessageConnectionImpl impl = new MessageConnectionImpl( - me, connectionSet, connection.getSenderAddress(), connection); + me, connectionSet, connection.getSenderAddress(), connection, wireSecurity); /** * If the attempt to establish a connection failed we just give up. In Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -31,7 +31,11 @@ import org.smartfrog.services.anubis.partition.protocols.partitionmanager.ConnectionSet; import org.smartfrog.services.anubis.partition.util.Identity; import org.smartfrog.services.anubis.partition.wire.Wire; +import org.smartfrog.services.anubis.partition.wire.WireMsg; import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; +import org.smartfrog.services.anubis.partition.wire.msg.TimedMsg; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurityException; import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.sfcore.logging.LogSF; @@ -43,6 +47,9 @@ private MessageConnectionServer server = null; private ConnectionSet connectionSet = null; private boolean announceTerm = true; + private WireSecurity wireSecurity = null; + private long sendCount = 0; + private long receiveCount = 0; private LogSF log = null; /** @@ -50,40 +57,96 @@ */ private boolean ignoring = false; - public MessageConnectionImpl(Identity id, ConnectionSet cs, ConnectionAddress address, MessageConnection mc) { + public MessageConnectionImpl(Identity id, ConnectionSet cs, ConnectionAddress address, MessageConnection mc, WireSecurity sec) { super("Anubis: node " + mc.getSender().id + " Connection Comms", address); me = id; connectionSet = cs; messageConnection = mc; + wireSecurity = sec; setPriority(MAX_PRIORITY); log = LogFactory.getLog(this.getClass().toString()); } - public MessageConnectionImpl(Identity id, SocketChannel channel, MessageConnectionServer mcs, ConnectionSet cs) { + public MessageConnectionImpl(Identity id, SocketChannel channel, MessageConnectionServer mcs, ConnectionSet cs, WireSecurity sec) { super("Anubis: new Connection Comms", channel); me = id; server = mcs; connectionSet = cs; + wireSecurity = sec; setPriority(MAX_PRIORITY); log = LogFactory.getLog(this.getClass().toString()); } + + /************************************************************ SECURITY public void send(byte[] bytes) { super.send(bytes); } + ****************************************************************/ + public void send(TimedMsg tm) { + try { + tm.setOrder(sendCount); + sendCount++; + super.send( wireSecurity.toWireForm(tm) ); + } catch (Exception ex) { + if( log.isErrorEnabled() ) + log.error(me + " failed to marshall timed message: " + tm + " - shutting down connection", ex); + shutdown(); + } + } public void deliver(byte[] bytes) { if( ignoring ) return; + + WireMsg msg = null; + try { + msg = wireSecurity.fromWireForm(bytes); + + } catch (WireSecurityException ex) { + + if( log.isErrorEnabled() ) + log.error(me + "connection transport encountered security violation unmarshalling message - ignoring " ); // + this.getSender() ); + return; + + } catch (Exception ex) { + + if( log.isErrorEnabled() ) + log.error(me + "connection transport unable to unmarshall message " ); // + this.getSender() ); + shutdown(); + return; + } + + if( !(msg instanceof TimedMsg) ) { + + if( log.isErrorEnabled() ) + log.error(me + "connection transport received non timed message " ); // + this.getSender() ); + shutdown(); + return; + } + + TimedMsg tm = (TimedMsg)msg; + + if( tm.getOrder() != receiveCount ) { + if( log.isErrorEnabled() ) { + log.error(me + "connection transport has delivered a message out of order - shutting down"); + } + shutdown(); + return; + } + + if( messageConnection == null ) { - initialMsg(bytes); + initialMsg(tm); } else { - messageConnection.deliver(bytes); + messageConnection.deliver(tm); } } + + /*************************************************************************** SECURITY private void initialMsg(byte[] bytes) { Object obj = null; @@ -94,6 +157,15 @@ log.error(me + " failed to unmarshall initial message on new connection - shutdown", ex); shutdown(); } + ***************************************************************/ + + private void initialMsg(TimedMsg tm) { + + /** + * temporary - get rid of these SECURITY + */ + Object obj = tm; + TimedMsg bytes = tm; /** @@ -131,7 +203,7 @@ if( ((MessageConnection)con).assignImpl(this) ) { messageConnection = (MessageConnection)con; setName("Anubis: node " + con.getSender().id + " Connection Comms"); - messageConnection.deliver(bytes); + messageConnection.deliver(bytes); } else { if( log.isErrorEnabled() ) log.error(me + " failed to assign incoming connection from " + con.getSender().toString()); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -32,6 +32,7 @@ import org.smartfrog.services.anubis.partition.protocols.partitionmanager.ConnectionSet; import org.smartfrog.services.anubis.partition.util.Identity; import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.sfcore.logging.LogSF; @@ -56,6 +57,7 @@ private Identity me = null; private ConnectionSet connectionSet = null; private Set pending = new HashSet(); + private WireSecurity wireSecurity = null; private LogSF log = LogFactory.getLog(this.getClass().toString()); /** @@ -66,10 +68,11 @@ * @param cs - the connection set * @throws Exception - if problems with creating the server socket */ - public MessageConnectionServer(ConnectionAddress address, Identity id, ConnectionSet cs) throws Exception { + public MessageConnectionServer(ConnectionAddress address, Identity id, ConnectionSet cs, WireSecurity sec) throws Exception { super("Anubis: Connection Server", address.ipaddress.getHostName());// , address.port); me = id; connectionSet = cs; + wireSecurity = sec; setConnectionFactory(this); setPriority(MAX_PRIORITY); } @@ -90,8 +93,7 @@ } */ public void createConnection(SocketChannel channel) { - MessageConnectionImpl impl = new MessageConnectionImpl(me, channel, this, - connectionSet); + MessageConnectionImpl impl = new MessageConnectionImpl(me, channel, this, connectionSet, wireSecurity); impl.start(); pending.add(impl); } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServerFactory.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServerFactory.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServerFactory.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -19,19 +19,32 @@ */ package org.smartfrog.services.anubis.partition.comms.blocking; +import java.rmi.RemoteException; + import org.smartfrog.services.anubis.basiccomms.connectiontransport.ConnectionAddress; import org.smartfrog.services.anubis.partition.comms.IOConnectionServer; import org.smartfrog.services.anubis.partition.comms.IOConnectionServerFactory; import org.smartfrog.services.anubis.partition.protocols.partitionmanager.ConnectionSet; import org.smartfrog.services.anubis.partition.util.Identity; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; +import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; public class MessageConnectionServerFactory extends PrimImpl implements Prim, IOConnectionServerFactory { + + private WireSecurity wireSecurity; + public MessageConnectionServerFactory() throws Exception { super(); } + + public void sfDeploy() throws RemoteException, SmartFrogException { + super.sfDeploy(); + wireSecurity = (WireSecurity)sfResolve("security"); + } + public IOConnectionServer create(ConnectionAddress address, Identity id, ConnectionSet cs) throws Exception { - return new MessageConnectionServer(address, id, cs); + return new MessageConnectionServer(address, id, cs, wireSecurity); } } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/components.sf =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/components.sf 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/components.sf 2007-09-19 16:32:45 UTC (rev 5137) @@ -23,14 +23,17 @@ MulticastHeartbeatTransport extends Compound { sfExport false; sfClass "org.smartfrog.services.anubis.partition.comms.multicast.HeartbeatCommsFactory"; + security LAZY anubisParameters:security; } BlockingConnectionTransport extends Prim { sfExport false; sfClass "org.smartfrog.services.anubis.partition.comms.blocking.MessageConnectionServerFactory"; + security LAZY anubisParameters:security; } NonBlockingConnectionTransport extends Prim { sfExport false; sfClass "org.smartfrog.services.anubis.partition.comms.nonblocking.MessageNioServerFactory"; + security LAZY anubisParameters:security; } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatComms.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -32,6 +32,8 @@ import org.smartfrog.services.anubis.partition.wire.Wire; import org.smartfrog.services.anubis.partition.wire.msg.Heartbeat; import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurityException; import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.logging.LogFactory; @@ -41,6 +43,7 @@ private Identity me = null; private HeartbeatReceiver connectionSet = null; private Map messageHandlers = Collections.synchronizedMap(new HashMap()); + private WireSecurity wireSecurity = null; private LogSF log = LogFactory.getLog(this.getClass().toString()); /** @@ -50,10 +53,11 @@ private Object ingnoringMonitor = new Object(); - public HeartbeatComms(MulticastAddress address, HeartbeatReceiver cs, String threadName, Identity id) throws Exception { + public HeartbeatComms(MulticastAddress address, HeartbeatReceiver cs, String threadName, Identity id, WireSecurity sec) throws Exception { super(threadName, address); me = id; connectionSet = cs; + wireSecurity = sec; setPriority(Thread.MAX_PRIORITY); } @@ -61,11 +65,20 @@ Object obj = null; try { - obj = Wire.fromWire(bytes); - } catch (Exception ex) { + +// obj = Wire.fromWire(bytes); SECURITY + obj = wireSecurity.fromWireForm(bytes); + + } catch (WireSecurityException ex) { + if( log.isErrorEnabled() ) - log.error("Error reading wire form message", ex); + log.error(me + "multicast transport encountered security violation receiving message - ignoring the message " ); // + this.getSender() ); return; + + } catch (Exception ex) { + if( log.isErrorEnabled() ) + log.error(me + "Error reading wire form message - ignoring", ex); + return; } if (obj instanceof Heartbeat) @@ -134,7 +147,8 @@ * @param msg message to send. */ public void sendHeartbeat(HeartbeatMsg msg) { - try { super.sendObject(msg.toWire()); } +// try { super.sendObject(msg.toWire()); } SECURITY + try { super.sendObject(wireSecurity.toWireForm(msg)); } catch (Exception ex) { if( log.isErrorEnabled() ) log.error("Error sending heartbeat message", ex); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatCommsFactory.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatCommsFactory.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/multicast/HeartbeatCommsFactory.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -19,17 +19,30 @@ */ package org.smartfrog.services.anubis.partition.comms.multicast; +import java.rmi.RemoteException; + import org.smartfrog.services.anubis.basiccomms.multicasttransport.MulticastAddress; import org.smartfrog.services.anubis.partition.protocols.heartbeat.HeartbeatReceiver; import org.smartfrog.services.anubis.partition.util.Identity; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; +import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; public class HeartbeatCommsFactory extends PrimImpl implements Prim { + + private WireSecurity wireSecurity = null; + public HeartbeatCommsFactory() throws Exception { super(); } + + public void sfDeploy() throws RemoteException, SmartFrogException { + super.sfDeploy(); + wireSecurity = (WireSecurity)sfResolve("security"); + } + public HeartbeatCommsIntf create(MulticastAddress address, HeartbeatReceiver cs, String threadName, Identity id) throws Exception { - return (HeartbeatCommsIntf)new HeartbeatComms(address, cs, threadName, id); + return (HeartbeatCommsIntf)new HeartbeatComms(address, cs, threadName, id, wireSecurity); } } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -34,8 +34,12 @@ import org.smartfrog.services.anubis.partition.protocols.partitionmanager.ConnectionSet; import org.smartfrog.services.anubis.partition.util.Identity; import org.smartfrog.services.anubis.partition.wire.Wire; +import org.smartfrog.services.anubis.partition.wire.WireMsg; import org.smartfrog.services.anubis.partition.wire.WireSizes; import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; +import org.smartfrog.services.anubis.partition.wire.msg.TimedMsg; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurityException; import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.sfcore.logging.LogSF; @@ -68,6 +72,7 @@ private boolean announceTerm = true; private boolean open = false; private boolean sendingDoneOK = false; + private WireSecurity wireSecurity = null; private RxQueue rxQueue = null; @@ -82,9 +87,10 @@ * from it and to write serialized objects onto it. A serialized object can be recovered by many calls from the selector thread * and serializing an object onto the socketChannel can occur in many chunks as well if the channel is busy. */ - public MessageNioHandler(Selector selector, SocketChannel sc, Vector deadKeys, Vector writePendingKeys, RxQueue rxQueue){ + public MessageNioHandler(Selector selector, SocketChannel sc, Vector deadKeys, Vector writePendingKeys, RxQueue rxQueue, WireSecurity sec){ if( debug && log.isTraceEnabled() ) log.trace("MNH: Constructing a new MessageNioHandler"); + this.wireSecurity = sec; this.sc = sc; this.deadKeys = deadKeys; this.writePendingKeys = writePendingKeys; @@ -370,7 +376,22 @@ // blocking write method: calls the above asynchronous one and this object needs to register itself as // a SendingListener - public synchronized void send(byte[] bytesToSend){ + + // public synchronized void send(byte[] bytesToSend){ // SECURITY + + public synchronized void send(TimedMsg tm){ + + byte[] bytesToSend = null; + try { + bytesToSend = wireSecurity.toWireForm(tm); + } catch (Exception ex) { + if( log.isErrorEnabled() ) + log.error(me + " failed to marshall timed message: " + tm + " - not sent", ex); + return; + } + + + if( debug && log.isTraceEnabled() ) log.trace("MNH: sendObject withOUT listener is being called"); sendingDoneOK = false; @@ -423,12 +444,50 @@ if (ignoring) return; - +/******************************************************** SECURITY if (messageConnection == null) { initialMsg(fullRxBuffer.array()); } else { messageConnection.deliver(fullRxBuffer.array()); } + ********************************************************************/ + + WireMsg msg = null; + try { + + msg = wireSecurity.fromWireForm(fullRxBuffer.array()); + + } catch (WireSecurityException ex) { + + if( log.isErrorEnabled() ) + log.error(me + "non blocking connection transport encountered security violation unmarshalling message - ignoring the message " ); // + this.getSender() ); + return; + + } catch (Exception ex) { + + if( log.isErrorEnabled() ) + log.error(me + "connection transport unable to unmarshall message " ); // + this.getSender() ); + shutdown(); + return; + } + + if( !(msg instanceof TimedMsg) ) { + + if( log.isErrorEnabled() ) + log.error(me + "connection transport received non timed message " ); // + this.getSender() ); + shutdown(); + return; + } + + TimedMsg tm = (TimedMsg)msg; + + + if( messageConnection == null ) { + initialMsg(tm); + } else { + messageConnection.deliver(tm); + } + } public void closing(){ @@ -482,9 +541,11 @@ // private methods // lifted from MessageConnectionImpl: I do not intend to modify it... - private void initialMsg(byte[] bytes) { - if( debug && log.isTraceEnabled() ) - log.trace("MNH: initialMsg is being called"); + + /*************************************************************** SECURITY + private void initialMsg(byte[] bytes) { + if( debug && log.isTraceEnabled() ) + log.trace("MNH: initialMsg is being called"); Object obj = null; try { @@ -494,7 +555,22 @@ log.error(me + " failed to unmarshall initial message on new connection - shutdown", ex); shutdown(); } + **********************************************************************/ + + + private void initialMsg(TimedMsg tm) { + + if( debug && log.isTraceEnabled() ) + log.trace("MNH: initialMsg is being called"); + /** + * temporary - get rid of these SECURITY + */ + Object obj = tm; + TimedMsg bytes = tm; + + + /** * must be a heartbeat message */ Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -39,6 +39,7 @@ import org.smartfrog.services.anubis.partition.protocols.partitionmanager.ConnectionSet; import org.smartfrog.services.anubis.partition.util.Identity; import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; import org.smartfrog.sfcore.logging.LogFactory; import org.smartfrog.sfcore.logging.LogImplAsyncWrapper; import org.smartfrog.sfcore.logging.LogSF; @@ -49,6 +50,7 @@ private Identity me = null; private ConnectionSet connectionSet = null; + private WireSecurity wireSecurity = null; private LogSF syncLog = LogFactory.getLog(this.getClass().toString()); private LogSF asyncLog = new LogImplAsyncWrapper( syncLog ); @@ -73,13 +75,14 @@ * A pre-defined number of worker threads deal with those RX deserialized jobs and deliver them to the anubis layers. By default there * is only 1 decoupling thread. */ - public MessageNioServer(ConnectionAddress address, Identity id, ConnectionSet cs) throws Exception { + public MessageNioServer(ConnectionAddress address, Identity id, ConnectionSet cs, WireSecurity sec) throws Exception { if( debug && asyncLog.isTraceEnabled() ) asyncLog.trace("MNS: constructing a new server"); me = id; connectionSet = cs; + wireSecurity = sec; // create a server try{ @@ -142,7 +145,7 @@ try{ SocketChannel sendingChannel = SocketChannel.open(); sendingChannel.configureBlocking(false); - mnh = new MessageNioHandler(selector, sendingChannel, deadKeys, writePendingKeys, assignRxQueue()); + mnh = new MessageNioHandler(selector, sendingChannel, deadKeys, writePendingKeys, assignRxQueue(), wireSecurity); mnh.init(me, cs, con, mci); sendingChannel.connect(new InetSocketAddress(conAd.ipaddress, conAd.port)); if( debug && asyncLog.isTraceEnabled() ) @@ -244,7 +247,7 @@ try{ SocketChannel clientChannel = server.accept(); clientChannel.configureBlocking(false); - MessageNioHandler conHandler = new MessageNioHandler(selector, clientChannel, deadKeys, writePendingKeys, assignRxQueue()); + MessageNioHandler conHandler = new MessageNioHandler(selector, clientChannel, deadKeys, writePendingKeys, assignRxQueue(), wireSecurity); conHandler.init(me, connectionSet); // only register for read - write is still enabled by default clientChannel.register(selector, SelectionKey.OP_READ, conHandler); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServerFactory.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServerFactory.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServerFactory.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -19,19 +19,33 @@ */ package org.smartfrog.services.anubis.partition.comms.nonblocking; +import java.rmi.RemoteException; + import org.smartfrog.services.anubis.basiccomms.connectiontransport.ConnectionAddress; import org.smartfrog.services.anubis.partition.comms.IOConnectionServer; import org.smartfrog.services.anubis.partition.comms.IOConnectionServerFactory; import org.smartfrog.services.anubis.partition.protocols.partitionmanager.ConnectionSet; import org.smartfrog.services.anubis.partition.util.Identity; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; +import org.smartfrog.sfcore.common.SmartFrogException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.prim.PrimImpl; public class MessageNioServerFactory extends PrimImpl implements Prim, IOConnectionServerFactory { + + private WireSecurity wireSecurity = null; + public MessageNioServerFactory() throws Exception { super(); } + + public void sfDeploy() throws RemoteException, SmartFrogException { + super.sfDeploy(); + wireSecurity = (WireSecurity)sfResolve("security"); + } + + public IOConnectionServer create(ConnectionAddress address, Identity id, ConnectionSet cs) throws Exception { - return new MessageNioServer(address, id, cs); + return new MessageNioServer(address, id, cs, wireSecurity); } } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -30,13 +30,15 @@ public class NonBlockingConnectionInitiator { private MessageConnection connection = null; - private byte[] heartbeat = null; +// private byte[] heartbeat = null; // SECURITY + private HeartbeatMsg heartbeat = null; private LogSF log = LogFactory.getLog(this.getClass().toString()); public NonBlockingConnectionInitiator(MessageConnection con, HeartbeatMsg hb) throws IOException, WireFormException { connection = con; - heartbeat = hb.toWire(); +// heartbeat = hb.toWire(); // SECURITY + heartbeat = hb; } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/components.sf =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/components.sf 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/components.sf 2007-09-19 16:32:45 UTC (rev 5137) @@ -20,7 +20,16 @@ #include "org/smartfrog/components.sf" #include "/org/smartfrog/services/anubis/basiccomms/components.sf" +NoSecurity extends Prim { + sfExport false; + sfClass "org.smartfrog.services.anubis.partition.wire.security.NoSecurityImpl"; +} +MACSecurity extends Prim { + sfExport false; + sfClass "org.smartfrog.services.anubis.partition.wire.security.MACSecurityImpl"; +} + TestMgr extends Compound { sfExport false; sfClass "org.smartfrog.services.anubis.partition.test.node.TestMgr"; @@ -42,7 +51,6 @@ heartbeatTimeout ATTRIB anubisParameters:heartbeatTimeout; } -// PartitionManager extends AnubisDefaultParameters { PartitionManager extends Compound { sfExport false; sfClass "org.smartfrog.services.anubis.partition.PartitionManager"; Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireFormException.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -28,4 +28,8 @@ public WireFormException(String str) { super(str); } + + public WireFormException(String str, Throwable thr) { + super(str, thr); + } } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/WireMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -24,8 +24,9 @@ public class WireMsg implements WireSizes { - protected ByteBuffer wireForm = null; - protected byte[] bytes = null; + protected ByteBuffer wireForm = null; + protected byte[] bytes = null; + protected int trailerSize = 0; public static final int WIRE_TYPE = 100; protected static final int WIRE_SIZE = intSz; @@ -42,7 +43,24 @@ * @return int * @throws WireFormException */ - protected int getSize() throws WireFormException { return WIRE_SIZE; } + public int getSize() throws WireFormException { return WIRE_SIZE; } + + /** + * Set the size of the trailer. When the message is converted to its + * wire form, the byte array will include a sequence of unused + * bytes equal to the trailer size at the end. The byte array length will + * be getSize() + trailerSize. + * + * @param n + * @throws WireFormException + */ + public void setTrailerSize(int n) throws WireFormException { + if( n < 0 ) { + throw new WireFormException("Negative trailer size specified: " + n); + } else { + trailerSize = n; + } + } /** * Default constructor - used when constructing from wire form @@ -81,7 +99,7 @@ fixDynamicSizedAttributes(); - bytes = new byte[getSize()]; + bytes = new byte[getSize() + trailerSize]; wireForm = ByteBuffer.wrap(bytes); writeWireForm(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/CloseMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/CloseMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/CloseMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -30,7 +30,7 @@ public static final int CLOSE_MSG_WIRE_SIZE = HEARTBEAT_MSG_WIRE_SIZE; protected int getType() { return CLOSE_MSG_WIRE_TYPE; } - protected int getSize() { return CLOSE_MSG_WIRE_SIZE; } + public int getSize() { return CLOSE_MSG_WIRE_SIZE; } /** * Construct a close message that matches the heartbeat messsage Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/HeartbeatMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -79,7 +79,7 @@ public static final int HEARTBEAT_MSG_WIRE_TYPE = 300; protected int getType() { return HEARTBEAT_MSG_WIRE_TYPE; } - protected int getSize() { return HEARTBEAT_MSG_WIRE_SIZE; } + public int getSize() { return HEARTBEAT_MSG_WIRE_SIZE; } protected HeartbeatMsg() { super(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/MessageMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -42,10 +42,10 @@ public static final int MESSAGE_MSG_WIRE_SIZE = UNDEFINED_SIZE; protected int getType() { return MESSAGE_MSG_WIRE_TYPE; } - protected int getSize() throws WireFormException { + public int getSize() throws WireFormException { if( payloadSz == UNDEFINED_SIZE ) throw new WireFormException("Attampt to get size of message when it has not been defined"); - return payloadLengthIdx + payloadSz + intSz; + return payloadIdx + payloadSz; } protected MessageMsg() { @@ -118,8 +118,8 @@ ObjectInputStream objectIS = new ObjectInputStream(byteArrayIS); message = objectIS.readObject(); - payload = null; - payloadSz = UNDEFINED_SIZE; +// payload = null; +// payloadSz = UNDEFINED_SIZE; } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingCloseMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingCloseMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingCloseMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -29,7 +29,7 @@ public static final int CLOSE_MSG_WIRE_SIZE = HEARTBEAT_MSG_WIRE_SIZE; protected int getType() { return CLOSE_MSG_WIRE_TYPE; } - protected int getSize() { return CLOSE_MSG_WIRE_SIZE; } + public int getSize() { return CLOSE_MSG_WIRE_SIZE; } /** * Construct a close message that matches the heartbeat messsage Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/PingHeartbeatMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -42,7 +42,7 @@ return PING_HEARTBEAT_MSG_WIRE_TYPE; } - protected int getSize() { + public int getSize() { return PING_HEARTBEAT_MSG_WIRE_SIZE; } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -32,6 +32,7 @@ public class TimedMsg extends WireMsg implements Timed, Sender { protected long time; + protected long order; protected Identity sender; protected ConnectionAddress address = null; @@ -39,7 +40,9 @@ static final private int timeIdx = WIRE_SIZE; static final private int timeSz = longSz; - static final private int identityIdx = timeIdx + timeSz; + static final private int orderIdx = timeIdx + timeSz; + static final private int orderSz = longSz; + static final private int identityIdx = orderIdx + orderSz; static final private int identitySz = Identity.identityWireSz; static final private int addressIdx = identityIdx + identitySz; static final private int addressSz = ConnectionAddress.connectionAddressWireSz; @@ -48,7 +51,7 @@ public static final int TIMED_MSG_WIRE_TYPE = 200; protected int getType() { return TIMED_MSG_WIRE_TYPE; } - protected int getSize() throws WireFormException { return TIMED_MSG_WIRE_SIZE; } + public int getSize() throws WireFormException { return TIMED_MSG_WIRE_SIZE; } protected TimedMsg() { super(); @@ -94,6 +97,13 @@ */ public long getTime() { return time; } public void setTime(long t) { time = t; } + + /** + * Msg order (only used in ordered connections) + * @return + */ + public long getOrder() { return order; } + public void setOrder(long o){ order = o; } /** * Sender interface implemenation @@ -131,6 +141,7 @@ protected void readWireForm(ByteBuffer buf) throws IOException, WireFormException, ClassNotFoundException { super.readWireForm(buf); time = wireForm.getLong(timeIdx); + order = wireForm.getLong(orderIdx); sender = Identity.readWireForm(wireForm, identityIdx); address = ConnectionAddress.readWireForm(wireForm, addressIdx); } @@ -142,6 +153,7 @@ protected void writeWireForm() throws WireFormException { super.writeWireForm(); wireForm.putLong(timeIdx, time); + wireForm.putLong(orderIdx, order); sender.writeWireForm(wireForm, identityIdx); if( address != null ) address.writeWireForm(wireForm, addressIdx); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java 2007-09-19 15:54:42 UTC (rev 5136) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/untimed/SerializedMsg.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -44,10 +44,10 @@ public static final int MESSAGE_MSG_WIRE_SIZE = UNDEFINED_SIZE; protected int getType() { return SERIALIZED_MSG_WIRE_TYPE; } - protected int getSize() throws WireFormException { + public int getSize() throws WireFormException { if( payloadSz == UNDEFINED_SIZE ) throw new WireFormException("Attampt to get size of message when it has not been defined"); - return payloadLengthIdx + payloadSz + intSz; + return payloadIdx + payloadSz; } protected SerializedMsg() { @@ -114,8 +114,8 @@ ObjectInputStream objectIS = new ObjectInputStream(byteArrayIS); msg = objectIS.readObject(); - payload = null; - payloadSz = UNDEFINED_SIZE; +// payload = null; +// payloadSz = UNDEFINED_SIZE; } /** * Writes the timed message attributes to wire form in the given byte Added: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/MACSecurityImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/MACSecurityImpl.java (rev 0) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/MACSecurityImpl.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -0,0 +1,63 @@ +package org.smartfrog.services.anubis.partition.wire.security; + +import java.io.IOException; +import java.rmi.RemoteException; + +import javax.crypto.ShortBufferException; + +import org.smartfrog.services.anubis.partition.wire.Wire; +import org.smartfrog.services.anubis.partition.wire.WireFormException; +import org.smartfrog.services.anubis.partition.wire.WireMsg; +import org.smartfrog.sfcore.common.SmartFrogException; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.PrimImpl; +import org.smartfrog.sfcore.security.MACData; + +public class MACSecurityImpl extends PrimImpl implements Prim, WireSecurity { + + private MACData macData = null; + + public MACSecurityImpl() throws RemoteException { + super(); + } + + public void sfDeploy() throws RemoteException, SmartFrogException { + super.sfDeploy(); + macData = new MACData(); + } + + public WireMsg fromWireForm(byte[] wireForm) throws WireSecurityException, WireFormException { + try { + + WireMsg msg = Wire.fromWire(wireForm); + macData.checkMAC(wireForm, 0, msg.getSize()-1); + + return msg; + } catch (ClassNotFoundException e) { + throw new WireFormException("Unable to unmarshall message", e); + } catch (IOException e) { + throw new WireFormException("Unable to unmarshall message", e); + } catch(SecurityException e) { + throw new WireSecurityException("Security violation unmarshalling message", e); + } + } + + public byte[] toWireForm(WireMsg msg) throws WireFormException { + try { + + msg.setTrailerSize(macData.getMacSize()); +// msg.setTrailerSize(100); + byte[] wireForm = msg.toWire(); + macData.addMAC(wireForm, 0, msg.getSize()-1); + return wireForm; + + } catch (IOException e) { + throw new WireFormException("Unable to marshall message", e); + } catch (ShortBufferException e) { + throw new WireFormException("Unable to marshall message - buffer not large enough for MAC security data", e); + } catch (SecurityException e) { + throw new WireFormException("Unable to marshall message - security issue", e); + } + } + +} Added: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/NoSecurityImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/NoSecurityImpl.java (rev 0) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/NoSecurityImpl.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -0,0 +1,34 @@ +package org.smartfrog.services.anubis.partition.wire.security; + +import java.io.IOException; +import java.rmi.RemoteException; + +import org.smartfrog.services.anubis.partition.wire.Wire; +import org.smartfrog.services.anubis.partition.wire.WireFormException; +import org.smartfrog.services.anubis.partition.wire.WireMsg; +import org.smartfrog.sfcore.prim.Prim; +import org.smartfrog.sfcore.prim.PrimImpl; + +public class NoSecurityImpl extends PrimImpl implements Prim, WireSecurity { + + public NoSecurityImpl() throws RemoteException { + super(); + } + + public WireMsg fromWireForm(byte[] wireFrom) throws WireSecurityException, WireFormException { + try { + return Wire.fromWire(wireFrom); + } catch (Exception e) { + throw new WireFormException("Unable to unmarshall message"); + } + } + + public byte[] toWireForm(WireMsg msg) throws WireFormException { + try { + return msg.toWire(); + } catch (IOException e) { + throw new WireFormException("Unable to marshall message"); + } + } + +} Added: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurity.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurity.java (rev 0) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurity.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -0,0 +1,11 @@ +package org.smartfrog.services.anubis.partition.wire.security; + +import org.smartfrog.services.anubis.partition.wire.WireFormException; +import org.smartfrog.services.anubis.partition.wire.WireMsg; + +public interface WireSecurity { + + public byte[] toWireForm(WireMsg msg) throws WireFormException; + public WireMsg fromWireForm(byte[] bytes) throws WireSecurityException, WireFormException; + +} Added: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurityException.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurityException.java (rev 0) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/security/WireSecurityException.java 2007-09-19 16:32:45 UTC (rev 5137) @@ -0,0 +1,13 @@ +package org.smartfrog.services.anubis.partition.wire.security; + +public class WireSecurityException extends SecurityException { + + public WireSecurityException(String msg) { + super(msg); + } + + public WireSecurityException(String msg, Throwable thr) { + super(msg, thr); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pau...@us...> - 2007-10-22 16:10:18
|
Revision: 5353 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=5353&view=rev Author: paul_murray Date: 2007-10-22 09:10:16 -0700 (Mon, 22 Oct 2007) Log Message: ----------- Corrected message order and security signing for non-blocking coms and both connection initiation protocols. Related to SFOS-447 Modified Paths: -------------- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/basiccomms/connectiontransport/ConnectionServer.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -122,6 +122,10 @@ listenSocket.socket().bind(new InetSocketAddress(inetAddress, port)); } catch(IOException ioex) { + + if( log.isDebugEnabled() ) { + log.debug("Failed to create server socket: ", ioex); + } listenSocket = null; open = false; Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/IOConnection.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -24,6 +24,8 @@ public interface IOConnection { + + public static int INITIAL_MSG_ORDER = 0; public void terminate(); public void silent(); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/BlockingConnectionInitiator.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -23,29 +23,35 @@ import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; import org.smartfrog.services.anubis.partition.util.Identity; +import org.smartfrog.services.anubis.partition.comms.IOConnection; import org.smartfrog.services.anubis.partition.comms.MessageConnection; import java.io.IOException; import org.smartfrog.services.anubis.partition.wire.WireFormException; +import org.smartfrog.sfcore.logging.LogFactory; +import org.smartfrog.sfcore.logging.LogSF; public class BlockingConnectionInitiator extends Thread { - + private Identity me = null; private ConnectionSet connectionSet = null; private MessageConnection connection = null; private HeartbeatMsg heartbeat = null; private WireSecurity wireSecurity = null; + private LogSF log = LogFactory.getLog(this.getClass().toString()); public BlockingConnectionInitiator(Identity id, MessageConnection con, ConnectionSet cset, - HeartbeatMsg hb) throws IOException, + HeartbeatMsg hb, + WireSecurity sec) throws IOException, WireFormException { super(); me = id; connection = con; connectionSet = cset; heartbeat = hb; + wireSecurity = sec; } /** @@ -54,7 +60,7 @@ * connections is an asynchronous task. */ public void run() { - + MessageConnectionImpl impl = new MessageConnectionImpl( me, connectionSet, connection.getSenderAddress(), connection, wireSecurity); @@ -62,10 +68,26 @@ * If the attempt to establish a connection failed we just give up. In * time the MessageConnection will time out. */ - if( !impl.connected() ) + if( !impl.connected() ) { + if( log.isDebugEnabled() ) { + log.debug("Blocking connection initiator failed to establish a connection"); + } return; + } - impl.send(heartbeat); + /** + * Set the order to be the initial message and + * send with security + */ + try { + heartbeat.setOrder(IOConnection.INITIAL_MSG_ORDER); + impl.send( wireSecurity.toWireForm(heartbeat) ); + } catch (WireFormException e) { + if( log.isErrorEnabled() ) { + log.error(me + " failed to marshall timed message: " + heartbeat, e); + } + return; + } /** * If the implementation is successfully assigned then start its thread Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionImpl.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -48,8 +48,8 @@ private ConnectionSet connectionSet = null; private boolean announceTerm = true; private WireSecurity wireSecurity = null; - private long sendCount = 0; - private long receiveCount = 0; + private long sendCount = INITIAL_MSG_ORDER; + private long receiveCount = INITIAL_MSG_ORDER; private LogSF log = LogFactory.getLog(this.getClass().toString()); /** @@ -128,12 +128,16 @@ } shutdown(); return; - } + } - + /** + * handle the message. We do not increment the order for the + * initial heartbeat message opening a new connection. + */ if( messageConnection == null ) { initialMsg(tm); } else { + receiveCount++; messageConnection.deliver(tm); } } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/blocking/MessageConnectionServer.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -130,8 +130,7 @@ public void initiateConnection(Identity id, MessageConnection con, HeartbeatMsg hb) { BlockingConnectionInitiator initiator = null; try { - initiator = new BlockingConnectionInitiator(id, con, connectionSet, - hb); + initiator = new BlockingConnectionInitiator(id, con, connectionSet, hb, wireSecurity); } catch (Exception ex) { if( log.isErrorEnabled() ) log.error("Error initiating a blocking connection", ex); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioHandler.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -73,6 +73,8 @@ private boolean open = false; private boolean sendingDoneOK = false; private WireSecurity wireSecurity = null; + private long sendCount = INITIAL_MSG_ORDER; + private long receiveCount = INITIAL_MSG_ORDER; private RxQueue rxQueue = null; @@ -374,22 +376,28 @@ } + // blocking write method: calls the above asynchronous one and this object needs to register itself as - // a SendingListener - + // a SendingListener public synchronized void send(TimedMsg tm){ byte[] bytesToSend = null; try { + tm.setOrder(sendCount); + sendCount++; bytesToSend = wireSecurity.toWireForm(tm); } catch (Exception ex) { if( log.isErrorEnabled() ) log.error(me + " failed to marshall timed message: " + tm + " - not sent", ex); return; } + + send(bytesToSend); + } + // only called directly from NonBlockingConnectionInitiator + public synchronized void send(byte[] bytesToSend) { - if( debug && log.isTraceEnabled() ) log.trace("MNH: sendObject withOUT listener is being called"); sendingDoneOK = false; @@ -472,10 +480,22 @@ TimedMsg tm = (TimedMsg)msg; - + if( tm.getOrder() != receiveCount ) { + if( log.isErrorEnabled() ) { + log.error(me + "connection transport has delivered a message out of order - shutting down"); + } + shutdown(); + return; + } + + /** + * handle the message. We do not increment the order for the + * initial heartbeat message opening a new connection. + */ if( messageConnection == null ) { initialMsg(tm); } else { + receiveCount++; messageConnection.deliver(tm); } Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/MessageNioServer.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -420,7 +420,7 @@ public void initiateConnection(Identity id, MessageConnection con, HeartbeatMsg hb) { NonBlockingConnectionInitiator initiator = null; try { - initiator = new NonBlockingConnectionInitiator(con, hb); + initiator = new NonBlockingConnectionInitiator(con, hb, wireSecurity); } catch (Exception ex) { if (asyncLog.isWarnEnabled()) asyncLog.warn(ex); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/comms/nonblocking/NonBlockingConnectionInitiator.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -21,9 +21,11 @@ import java.io.IOException; +import org.smartfrog.services.anubis.partition.comms.IOConnection; import org.smartfrog.services.anubis.partition.comms.MessageConnection; import org.smartfrog.services.anubis.partition.wire.WireFormException; import org.smartfrog.services.anubis.partition.wire.msg.HeartbeatMsg; +import org.smartfrog.services.anubis.partition.wire.security.WireSecurity; import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.logging.LogFactory; @@ -31,19 +33,29 @@ private MessageConnection connection = null; private HeartbeatMsg heartbeat = null; + private WireSecurity wireSecurity = null; private LogSF log = LogFactory.getLog(this.getClass().toString()); - public NonBlockingConnectionInitiator(MessageConnection con, HeartbeatMsg hb) throws IOException, + public NonBlockingConnectionInitiator(MessageConnection con, HeartbeatMsg hb, WireSecurity sec) throws IOException, WireFormException { connection = con; heartbeat = hb; + wireSecurity = sec; } public void finishNioConnect(MessageNioHandler impl) { if ( (impl.isReadyForWriting()) && (impl.connected())) { - impl.send(heartbeat); + try { + heartbeat.setOrder(IOConnection.INITIAL_MSG_ORDER); + impl.send( wireSecurity.toWireForm(heartbeat) ); + } catch (WireFormException e) { + if( log.isErrorEnabled() ) { + log.error("MCI: failed to marshall timed message: " + heartbeat, e); + } + return; + } } else { if( log.isErrorEnabled() ) Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/protocols/partitionmanager/ConnectionSet.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -164,6 +164,7 @@ ConnectionAddress connectionAddress = ((ConnectionAddressData)sfResolve("contactAddress")).getConnectionAddress(); IOConnectionServerFactory factory = (IOConnectionServerFactory)sfResolve("connectionServerFactory"); connectionServer = (IOConnectionServer)factory.create(connectionAddress, me, this); + SelfConnection self = new SelfConnection(me, connectionView, connectionServer.getAddress(), isPreferredLeaderNode); Modified: trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java =================================================================== --- trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2007-10-22 12:10:31 UTC (rev 5352) +++ trunk/core/components/anubis/src/org/smartfrog/services/anubis/partition/wire/msg/TimedMsg.java 2007-10-22 16:10:16 UTC (rev 5353) @@ -122,7 +122,7 @@ * @return String */ public String toString() { - return "[" + time + ", " + (addressUnmarshalled ? sender.toString() : "SENDER_ADDRESS_MARSHALLED") + ", " + address + "]"; + return "[" + time + ", " + order + ", " + (addressUnmarshalled ? sender.toString() : "SENDER_ADDRESS_MARSHALLED") + ", " + address + "]"; } private void addressFromWire() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |