You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wadi-commits@incubator.apache.org by bd...@apache.org on 2005/12/14 23:36:16 UTC
svn commit: r356933 [7/35] - in /incubator/wadi/trunk: ./ etc/ modules/
modules/assembly/ modules/assembly/src/ modules/assembly/src/bin/
modules/assembly/src/conf/ modules/assembly/src/main/
modules/assembly/src/main/assembly/ modules/core/ modules/co...
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferAcknowledgement.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferAcknowledgement.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferAcknowledgement.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferAcknowledgement.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.messages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.OldMessage;
+
+public class PartitionTransferAcknowledgement implements OldMessage, Serializable {
+
+ protected boolean _success;
+
+ public PartitionTransferAcknowledgement(boolean success) {
+ _success=success;
+ }
+
+ protected PartitionTransferAcknowledgement() {
+ // used during deserialisation...
+ }
+
+ public boolean getSuccess() {
+ return _success;
+ }
+
+
+ public String toString() {
+ return "<PartitionTransferAcknowledgement: "+_success+">";
+ }
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferCommand.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferCommand.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferCommand.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferCommand.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,49 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.messages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.OldMessage;
+import org.codehaus.wadi.dindex.impl.PartitionTransfer;
+
+public class PartitionTransferCommand implements OldMessage, Serializable {
+
+ protected PartitionTransfer[] _transfers;
+
+ public PartitionTransferCommand(PartitionTransfer[] transfers) {
+ _transfers=transfers;
+ }
+
+ protected PartitionTransferCommand() {
+ // for deserialisation...
+ }
+
+ public PartitionTransfer[] getTransfers() {
+ return _transfers;
+ }
+
+
+ public String toString() {
+ StringBuffer buffer=new StringBuffer("<PartitionTransferCommand: ");
+ for (int i=0; i<_transfers.length; i++)
+ buffer.append((i==0?"":",")+_transfers[i]);
+ buffer.append(">");
+ return buffer.toString();
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferRequest.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferRequest.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferRequest.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferRequest.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.messages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.OldMessage;
+import org.codehaus.wadi.dindex.impl.LocalPartition;
+
+public class PartitionTransferRequest implements OldMessage, Serializable {
+
+ protected long _timeStamp;
+ protected LocalPartition[] _partitions;
+
+ public PartitionTransferRequest(long timeStamp, LocalPartition[] partitions) {
+ _timeStamp=timeStamp;
+ _partitions=partitions;
+ }
+
+ protected PartitionTransferRequest() {
+ // for deserialisation
+ }
+
+ public long getTimeStamp() {
+ return _timeStamp;
+ }
+
+ public LocalPartition[] getPartitions() {
+ return _partitions;
+ }
+
+ public String toString() {
+ StringBuffer buffer=new StringBuffer("<PartitionTransferRequest: ");
+ for (int i=0; i<_partitions.length; i++)
+ buffer.append((i==0?"":",")+_partitions[i]);
+ buffer.append(">");
+ return buffer.toString();
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferResponse.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferResponse.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferResponse.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/PartitionTransferResponse.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.messages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.OldMessage;
+
+public class PartitionTransferResponse implements OldMessage, Serializable {
+
+ protected boolean _success;
+
+ public PartitionTransferResponse(boolean success) {
+ _success=success;
+ }
+
+ protected PartitionTransferResponse() {
+ // used during deserialisation...
+ }
+
+ public boolean getSuccess() {
+ return _success;
+ }
+
+ public String toString() {
+ return "<PartitionTransferResponse: "+_success+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationAcknowledgement.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationAcknowledgement.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationAcknowledgement.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationAcknowledgement.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,30 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.messages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.OldMessage;
+
+public class RelocationAcknowledgement implements OldMessage, Serializable {
+ // NYI
+
+ public String toString() {
+ return "<RelocationAcknowledgement>";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationRequest.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationRequest.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationRequest.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationRequest.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.messages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.OldMessage;
+import org.codehaus.wadi.dindex.impl.AbstractDIndexRequest;
+
+public class RelocationRequest extends AbstractDIndexRequest implements OldMessage, Serializable {
+
+ private String _sessionName;
+ private String _nodeName;
+ private int _numConcurrentInvocations;
+ private boolean _shuttingDown;
+
+ public RelocationRequest(String sessionName, String nodeName, int numConcurrentInvocations, boolean shuttingDown) {
+ super(sessionName);
+ _sessionName=sessionName;
+ _nodeName=nodeName;
+ _numConcurrentInvocations=numConcurrentInvocations;
+ _shuttingDown=shuttingDown;
+ }
+
+ protected RelocationRequest() {
+ // used when deserialising
+ }
+
+ public String getSessionName() {
+ return _sessionName;
+ }
+
+ public String getNodeName() {
+ return _nodeName;
+ }
+
+ public int getNumConcurrentInvocations() {
+ return _numConcurrentInvocations;
+ }
+
+ public boolean getShuttingDown() {
+ return _shuttingDown;
+ }
+
+ public String toString() {
+ return "<RelocationRequestI2P: "+_sessionName+" -> "+_nodeName+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationResponse.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationResponse.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationResponse.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/messages/RelocationResponse.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,80 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.messages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.Motable;
+import org.codehaus.wadi.OldMessage;
+import org.codehaus.wadi.ProxiedLocation;
+
+public class RelocationResponse implements OldMessage, Serializable {
+
+ protected String _sessionName;
+ protected String _nodeName;
+ protected Motable _motable;
+ protected ProxiedLocation _location;
+
+ // use when relocating session...
+ public RelocationResponse(String sessionName, String nodeName, Motable motable) {
+ _sessionName=sessionName;
+ _nodeName=nodeName;
+ _motable=motable;
+ _location=null;
+ }
+
+ // use when relocating request...
+ public RelocationResponse(String sessionName, String nodeName, ProxiedLocation location) {
+ _sessionName=sessionName;
+ _nodeName=nodeName;
+ _motable=null;
+ _location=location;
+ }
+
+ // use when session was not found...
+ public RelocationResponse(String sessionName) {
+ _sessionName=sessionName;
+ _nodeName=null;
+ _motable=null;
+ _location=null;
+ }
+
+ protected RelocationResponse() {
+ // for deserialising
+ }
+
+ public String getSessionName() {
+ return _sessionName;
+ }
+
+ public String getNodeName() {
+ return _nodeName;
+ }
+
+ public Motable getMotable() {
+ return _motable;
+ }
+
+ public ProxiedLocation getProxiedLocation() {
+ return _location;
+ }
+
+ public String toString() {
+ return "<RelocationResponse: "+_sessionName+" -> "+_nodeName+": "+(_motable!=null?"session":_location!=null?"request":"failed")+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeleteIMToPM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeleteIMToPM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeleteIMToPM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeleteIMToPM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.dindex.impl.AbstractDIndexRequest;
+
+/**
+ * Sent from InvocationMaster to PartitionMaster requesting that an entry be removed from the index.
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeleteIMToPM extends AbstractDIndexRequest implements Serializable {
+
+ public DeleteIMToPM(String name) {
+ super(name);
+ }
+
+ public String toString() {
+ return "<DeleteIMToPM:"+_key+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeletePMToIM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeletePMToIM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeletePMToIM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/DeletePMToIM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.dindex.DIndexResponse;
+
+/**
+ * Sent, from PartitionMaster to InvocationMaster, confirming removal of an item from the Partition's index.
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.1 $
+ */
+public class DeletePMToIM implements DIndexResponse, Serializable {
+
+ public DeletePMToIM() {
+ super(); // TODO - should not need key
+ }
+
+ public String toString() {
+ return "<DeletePMToIM>";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertIMToPM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertIMToPM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertIMToPM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertIMToPM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,33 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.dindex.impl.AbstractDIndexRequest;
+
+public class InsertIMToPM extends AbstractDIndexRequest implements Serializable {
+
+ public InsertIMToPM(String name) {
+ super(name);
+ }
+
+ public String toString() {
+ return "<InsertIMToPM:"+_key+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertPMToIM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertPMToIM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertPMToIM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/InsertPMToIM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.dindex.DIndexResponse;
+
+public class InsertPMToIM implements DIndexResponse, Serializable {
+
+ protected boolean _success;
+
+ public InsertPMToIM(boolean success) {
+ super();
+ _success=success;
+ }
+
+ public boolean getSuccess() {
+ return _success;
+ }
+
+ public String toString() {
+ return "<InsertPMToIM:"+_success+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToPM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToPM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToPM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToPM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.OldMessage;
+import org.codehaus.wadi.dindex.impl.AbstractDIndexRequest;
+
+public class MoveIMToPM extends AbstractDIndexRequest implements OldMessage, Serializable {
+
+ private String _nodeName;
+ private int _numConcurrentInvocations;
+ private boolean _shuttingDown;
+
+ public MoveIMToPM(String sessionName, String nodeName, int numConcurrentInvocations, boolean shuttingDown) {
+ super(sessionName);
+ _nodeName=nodeName;
+ _numConcurrentInvocations=numConcurrentInvocations;
+ _shuttingDown=shuttingDown;
+ }
+
+ protected MoveIMToPM() {
+ // used when deserialising
+ }
+
+ public String getNodeName() {
+ return _nodeName;
+ }
+
+ public int getNumConcurrentInvocations() {
+ return _numConcurrentInvocations;
+ }
+
+ public boolean getShuttingDown() {
+ return _shuttingDown;
+ }
+
+ public String toString() {
+ return "<MoveIMToPM:"+_key+"->"+_nodeName+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToSM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToSM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToSM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveIMToSM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+public class MoveIMToSM implements Serializable {
+
+ protected boolean _success;
+
+ public MoveIMToSM(boolean success) {
+ _success=success;
+ }
+
+ public MoveIMToSM() {
+ this(true);
+ }
+
+ public boolean getSuccess() {
+ return _success;
+ }
+
+ public String toString() {
+ return "<MoveIMToSM:"+_success+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToIM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToIM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToIM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToIM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+/**
+ * Response from PartitionMaster to InvocationMaster, indicating that required State does not exist.
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.1 $
+ */
+public class MovePMToIM implements Serializable {
+
+ public MovePMToIM() {
+ }
+
+ public String toString() {
+ return "<MovePMToIM:false>";
+ }
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToSM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToSM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToSM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MovePMToSM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import javax.jms.Destination;
+
+public class MovePMToSM implements Serializable {
+
+ protected Object _key;
+ protected Destination _im;
+ protected Destination _pm;
+ protected String _imCorrelationId;
+
+ public MovePMToSM(Object key, Destination im, Destination pm, String imCorrelationId) {
+ _key=key;
+ _im=im;
+ _pm=im;
+ _imCorrelationId=imCorrelationId;
+ }
+
+ protected MovePMToSM() {
+ // for deserialisation...
+ }
+
+ public Object getKey() {
+ return _key;
+ }
+
+ public Destination getIM() {
+ return _im;
+ }
+
+ public Destination getPM() {
+ return _pm;
+ }
+
+ public String getIMCorrelationId() {
+ return _imCorrelationId;
+ }
+
+ public String toString() {
+ return "<MovePMToSM:"+_key+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToIM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToIM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToIM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToIM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,49 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+public class MoveSMToIM implements Serializable {
+
+ protected Object _key; // do we really need the key - TODO
+ protected Object _value; // should be strictly typed to byte[] - TODO
+
+ public MoveSMToIM(Object key, Object value) {
+ _key=key;
+ _value=value;
+ }
+
+ protected MoveSMToIM() {
+ // for deserialisation...
+ }
+
+ public Object getKey() {
+ return _key;
+ }
+
+ public Object getValue() {
+ return _value;
+ }
+
+ public String toString() {
+ byte[] bytes=(byte[])_value;
+ int l=(bytes==null?0:bytes.length);
+ return "<MoveSMToIM:"+_key+":"+l+"bytes>";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToPM.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToPM.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToPM.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/MoveSMToPM.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+public class MoveSMToPM implements Serializable {
+
+ boolean _success;
+
+ public MoveSMToPM(boolean success) {
+ _success=success;
+ }
+
+ public MoveSMToPM() {
+ this(true);
+ }
+
+ public boolean getSuccess() {
+ return _success;
+ }
+
+ public String toString() {
+ return "<MoveSMToPM:"+_success+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryRequest.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryRequest.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryRequest.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryRequest.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.Motable;
+import org.codehaus.wadi.OldMessage;
+
+/**
+ * A request for the emigration of the enclosed session - The response
+ * should be a ReleaseEntryResponse object sent whence this request arrived.
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReleaseEntryRequest implements OldMessage, Serializable {
+ protected Motable _motable;
+
+ /**
+ *
+ */
+ public ReleaseEntryRequest(Motable motable) {
+ super();
+ _motable=motable;
+ }
+
+ public ReleaseEntryRequest() {
+ // for use when demarshalling...
+ }
+
+ public Motable getMotable() {
+ return _motable;
+ }
+
+ public String toString() {
+ return "<EmigrationRequest: "+_motable.getName()+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryResponse.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryResponse.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryResponse.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/dindex/newmessages/ReleaseEntryResponse.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.dindex.newmessages;
+
+import java.io.Serializable;
+
+import org.codehaus.wadi.Location;
+import org.codehaus.wadi.OldMessage;
+
+/**
+ * A query for the location of the session with the enclosed ID - The response
+ * should be a LocationResponse object sent whence this request arrived.
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReleaseEntryResponse implements OldMessage, Serializable {
+
+ protected String _name;
+ protected Location _location;
+
+ public ReleaseEntryResponse(String name, Location location) {
+ _name=name;
+ _location=location;
+ }
+
+ protected ReleaseEntryResponse() {
+ // for deserialisation ...
+ }
+
+ public String getId() {
+ return _name;
+ }
+
+ public Location getLocation() {
+ return _location;
+ }
+
+ public String toString() {
+ return "<EmigrationResponse: "+_name+">";
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Dispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Dispatcher.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Dispatcher.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Dispatcher.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,112 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import javax.jms.Destination;
+import javax.jms.ObjectMessage;
+
+import org.activecluster.ClusterListener;
+import org.codehaus.wadi.impl.Quipu;
+
+import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
+
+public interface Dispatcher {
+
+ interface InternalDispatcher {
+ void dispatch(ObjectMessage om, Serializable obj) throws Exception;
+ void incCount();
+ void decCount();
+ int getCount();
+ }
+
+
+ void init(DispatcherConfig config) throws Exception;
+
+ InternalDispatcher register(Object target, String methodName, Class type);
+
+ InternalDispatcher newRegister(Object target, String methodName, Class type);
+
+ boolean deregister(String methodName, Class type, int timeout);
+
+ boolean newDeregister(String methodName, Class type, int timeout);
+
+ void register(Class type, long timeout);
+
+ boolean send(Destination from, Destination to, String outgoingCorrelationId, Serializable body);
+
+ ObjectMessage exchangeSend(Destination from, Destination to, Serializable body, long timeout);
+
+ ObjectMessage exchangeSend(Destination from, Destination to, Serializable body, long timeout, String targetCorrelationId);
+
+ ObjectMessage exchangeSendLoop(Destination from, Destination to, Serializable body, long timeout, int iterations);
+
+ ObjectMessage exchangeSend(Destination from, Destination to, String outgoingCorrelationId, Serializable body, long timeout);
+
+ boolean reply(Destination from, Destination to, String incomingCorrelationId, Serializable body);
+
+ boolean reply(ObjectMessage message, Serializable body);
+
+ ObjectMessage exchangeReply(ObjectMessage message, Serializable body, long timeout);
+
+ ObjectMessage exchangeReplyLoop(ObjectMessage message, Serializable body, long timeout);
+
+ boolean forward(ObjectMessage message, Destination destination);
+
+ boolean forward(ObjectMessage message, Destination destination, Serializable body);
+
+ Map getRendezVousMap();
+
+ String nextCorrelationId();
+
+ Quipu setRendezVous(String correlationId, int numLlamas);
+
+ ObjectMessage attemptRendezVous(String correlationId, Quipu rv, long timeout);
+
+ // TODO - rather than owning this, we should be given a pointer to it at init()
+ // time, and this accessor should be removed...
+ PooledExecutor getExecutor();
+
+ Destination getLocalDestination();
+ Destination getClusterDestination();
+
+ Map getDistributedState();
+ void setDistributedState(Map state) throws Exception;
+
+ void start() throws Exception;
+ void stop() throws Exception;
+
+ String getNodeName(Destination destination);
+
+ String getIncomingCorrelationId(ObjectMessage message) throws Exception;
+ void setIncomingCorrelationId(ObjectMessage message, String correlationId) throws Exception;
+ String getOutgoingCorrelationId(ObjectMessage message) throws Exception;
+ void setOutgoingCorrelationId(ObjectMessage message, String correlationId) throws Exception;
+ void send(Destination to, ObjectMessage message) throws Exception;
+ ObjectMessage createObjectMessage() throws Exception;
+
+ String getNodeName();
+ long getInactiveTime();
+ int getNumNodes();
+
+ // yeugh - AC i/f is creeping in here - temporary...
+
+ void setClusterListener(ClusterListener listener);
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/DispatcherConfig.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/DispatcherConfig.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/DispatcherConfig.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/DispatcherConfig.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+public interface DispatcherConfig {
+
+ String getContextPath();
+
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/ExtendedCluster.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/ExtendedCluster.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/ExtendedCluster.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/ExtendedCluster.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import javax.jms.Connection;
+
+/**
+ * An ActiveCluster Cluster that exposes an API for the dynamic creation of Queues.
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.2 $
+ */
+public interface ExtendedCluster extends org.activecluster.Cluster /*, Lifecycle */ {
+
+ Connection getConnection();
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/LockManager.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/LockManager.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/LockManager.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/LockManager.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import EDU.oswego.cs.dl.util.concurrent.Sync;
+
+public interface LockManager {
+
+ Sync acquire(Object key);
+ //Sync acquire(Object key, Object value);
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Partition.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Partition.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Partition.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/Partition.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,41 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import java.util.Map;
+
+import javax.jms.Destination;
+
+import org.codehaus.wadi.PMPartition;
+import org.codehaus.wadi.gridstate.impl.Location;
+
+import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
+
+public interface Partition extends PMPartition {
+
+ void init(PartitionConfig config);
+
+ // Serializable executeSync(Object process);
+ // void executeASync(Object process);
+
+ Destination getDestination();
+
+ Location getLocation(Object key);
+ ReadWriteLock getLock();
+ Map getMap();
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionConfig.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionConfig.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionConfig.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionConfig.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import javax.jms.Destination;
+
+
+public interface PartitionConfig {
+
+ Destination getLocalDestination();
+ Dispatcher getDispatcher();
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManager.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManager.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManager.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManager.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import org.codehaus.wadi.gridstate.impl.PartitionFacade;
+
+public interface PartitionManager extends PartitionConfig {
+
+ void init(PartitionManagerConfig config);
+ void start() throws Exception;
+ void evacuate() throws Exception;
+ void stop() throws Exception;
+
+ int getNumPartitions();
+ PartitionFacade[] getPartitions();
+ PartitionFacade getPartition(Object key);
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManagerConfig.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManagerConfig.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManagerConfig.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionManagerConfig.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import javax.jms.Destination;
+
+public interface PartitionManagerConfig {
+
+ Destination getLocalDestination();
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionMapper.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionMapper.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionMapper.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/PartitionMapper.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,29 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+public interface PartitionMapper {
+
+ /**
+ * Given a key, map it to the corresponding Partition index.
+ *
+ * @param key
+ * @return
+ */
+ int map(Object key);
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManager.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManager.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManager.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManager.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import javax.jms.Destination;
+
+public interface StateManager {
+
+ void init(StateManagerConfig config);
+
+ // called on IM...
+ Object get(Object key);
+
+ // called on IM...
+ Object put(Object key, Object value, boolean overwrite, boolean returnOldValue);
+
+ Object remove(Object key, boolean returnOldValue);
+
+ void start() throws Exception;
+
+ void stop() throws Exception;
+
+ Object syncRpc(Destination destination, Object message) throws Exception;
+
+ //Object getLocalLocation();
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManagerConfig.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManagerConfig.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManagerConfig.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/StateManagerConfig.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate;
+
+import java.util.Map;
+
+import org.codehaus.wadi.gridstate.impl.PartitionFacade;
+
+
+public interface StateManagerConfig {
+
+ public Map getMap();
+ public LockManager getPMSyncs();
+ public LockManager getSMSyncs();
+
+ public PartitionFacade getPartition(Object key);
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/ActiveClusterDispatcher.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/ActiveClusterDispatcher.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/ActiveClusterDispatcher.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/ActiveClusterDispatcher.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,218 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate.activecluster;
+
+import java.util.Collection;
+import java.util.Map;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.ObjectMessage;
+
+import org.activecluster.Cluster;
+import org.activecluster.ClusterListener;
+import org.activecluster.Node;
+import org.activemq.ActiveMQConnection;
+import org.activemq.ActiveMQConnectionFactory;
+import org.activemq.broker.BrokerConnector;
+import org.activemq.broker.BrokerContainer;
+import org.activemq.store.vm.VMPersistenceAdapterFactory;
+import org.activemq.transport.TransportChannel;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.wadi.dindex.impl.DIndex;
+import org.codehaus.wadi.gridstate.DispatcherConfig;
+import org.codehaus.wadi.gridstate.ExtendedCluster;
+import org.codehaus.wadi.gridstate.impl.AbstractDispatcher;
+
+/**
+ * A Dispatcher for ActiveCluster
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.14 $
+ */
+public class ActiveClusterDispatcher extends AbstractDispatcher {
+
+ protected static String _incomingCorrelationIdKey="incomingCorrelationId";
+ protected static String _outgoingCorrelationIdKey="outgoingCorrelationId";
+
+ protected Cluster _cluster;
+ protected MessageConsumer _clusterConsumer;
+ protected MessageConsumer _nodeConsumer;
+
+ protected final String _clusterUri;
+
+ public ActiveClusterDispatcher(String nodeName, String clusterName, String clusterUri, long inactiveTime) {
+ super(nodeName, clusterName, inactiveTime);
+ _clusterUri=clusterUri;
+ _log=LogFactory.getLog(getClass()+"#"+_nodeName);
+ }
+
+ // 5 calls
+
+ public Cluster getCluster() {
+ return _cluster;
+ }
+
+ // soon to be obsolete...
+
+ public MessageConsumer addDestination(Destination destination) throws JMSException {
+ boolean excludeSelf=true;
+ MessageConsumer consumer=_cluster.createConsumer(destination, null, excludeSelf);
+ consumer.setMessageListener(this);
+ return consumer;
+ }
+
+ public void removeDestination(MessageConsumer consumer) throws JMSException {
+ consumer.close();
+ }
+
+ //-----------------------------------------------------------------------------------------------
+ // AbstractDispatcher overrides
+
+ protected ActiveMQConnectionFactory _connectionFactory;
+ public CustomClusterFactory _clusterFactory;
+
+ public void init(DispatcherConfig config) throws Exception {
+ super.init(config);
+ try {
+ _connectionFactory=new ActiveMQConnectionFactory(_clusterUri);
+ _connectionFactory.start();
+ System.setProperty("activemq.persistenceAdapterFactory", VMPersistenceAdapterFactory.class.getName()); // do we need this ?
+ _clusterFactory=new CustomClusterFactory(_connectionFactory);
+ _clusterFactory.setInactiveTime(_inactiveTime);
+ _cluster=(ExtendedCluster)_clusterFactory.createCluster(_clusterName);
+ } catch (Exception e) {
+ _log.error("problem starting Cluster", e);
+ }
+
+ boolean excludeSelf;
+ excludeSelf=false;
+ _clusterConsumer=_cluster.createConsumer(_cluster.getDestination(), null, excludeSelf);
+ _clusterConsumer.setMessageListener(this);
+ excludeSelf=false;
+ _nodeConsumer=_cluster.createConsumer(_cluster.getLocalNode().getDestination(), null, excludeSelf);
+ _nodeConsumer.setMessageListener(this);
+ }
+
+ //-----------------------------------------------------------------------------------------------
+ // Dispatcher API
+
+ public void start() throws Exception {
+ _cluster.start();
+ }
+
+ public void stop() throws Exception {
+ // shut down activemq cleanly - what happens if we are running more than one distributable webapp ?
+ // there must be an easier way - :-(
+ ActiveMQConnection connection=(ActiveMQConnection)((ExtendedCluster)_cluster).getConnection();
+ TransportChannel channel=(connection==null?null:connection.getTransportChannel());
+ BrokerConnector connector=(channel==null?null:channel.getEmbeddedBrokerConnector());
+ BrokerContainer container=(connector==null?null:connector.getBrokerContainer());
+ if (container!=null)
+ container.stop(); // for peer://
+
+ _cluster.stop();
+ _connectionFactory.stop();
+
+ Thread.sleep(5*1000);
+ }
+
+ public int getNumNodes() {
+ return _cluster.getNodes().size()+1; // TODO - really inefficient... - allocates a Map
+ }
+
+ public ObjectMessage createObjectMessage() throws Exception {
+ return _cluster.createObjectMessage();
+ }
+
+ public void send(Destination to, ObjectMessage message) throws Exception {
+ if (_messageLog.isTraceEnabled()) {
+ try {
+ _messageLog.trace("outgoing: "+message.getObject()+" {"+getNodeName(message.getJMSReplyTo())+"->"+getNodeName(message.getJMSDestination())+"} - "+getIncomingCorrelationId(message)+"/"+getOutgoingCorrelationId(message)+" on "+Thread.currentThread().getName());
+ } catch (JMSException e) {
+ _log.warn("problem extracting message content", e);
+ }
+ }
+ _cluster.send(to, message);
+ }
+
+ public Destination getLocalDestination() {
+ return _cluster.getLocalNode().getDestination();
+ }
+
+ public Destination getClusterDestination() {
+ return _cluster.getDestination();
+ }
+
+ public Map getDistributedState() {
+ return _cluster.getLocalNode().getState();
+ }
+
+ public void setDistributedState(Map state) throws Exception {
+ _cluster.getLocalNode().setState(state);
+ }
+
+ public String getNodeName(Destination destination) {
+ Node localNode=_cluster.getLocalNode();
+ Destination localDestination=localNode.getDestination();
+
+ if (destination==null) {
+ return "<NULL-DESTINATION>";
+ }
+
+ if (destination.equals(localDestination))
+ return DIndex.getNodeName(localNode);
+
+ Destination clusterDestination=_cluster.getDestination();
+ if (destination.equals(clusterDestination))
+ return "cluster";
+
+ Node node=null;
+ if ((node=(Node)_cluster.getNodes().get(destination))!=null)
+ return DIndex.getNodeName(node);
+
+ return "<unknown>";
+ }
+
+ public String getIncomingCorrelationId(ObjectMessage message) throws Exception {
+ return message.getStringProperty(_incomingCorrelationIdKey);
+ }
+
+ public void setIncomingCorrelationId(ObjectMessage message, String id) throws JMSException {
+ message.setStringProperty(_incomingCorrelationIdKey, id);
+ }
+
+ public String getOutgoingCorrelationId(ObjectMessage message) throws JMSException {
+ return message.getStringProperty(_outgoingCorrelationIdKey);
+ }
+
+ public void setOutgoingCorrelationId(ObjectMessage message, String id) throws JMSException {
+ message.setStringProperty(_outgoingCorrelationIdKey, id);
+ }
+
+ public void findRelevantSessionNames(int numPartitions, Collection[] resultSet) {
+ throw new UnsupportedOperationException("NYI");
+ }
+
+ // temporary
+
+ public void setClusterListener(ClusterListener listener) {
+ _cluster.addClusterListener(listener);
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomCluster.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomCluster.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomCluster.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomCluster.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate.activecluster;
+
+import java.util.Timer;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.activecluster.LocalNode;
+import org.activecluster.impl.DefaultCluster;
+import org.codehaus.wadi.gridstate.ExtendedCluster;
+
+public class CustomCluster extends DefaultCluster implements ExtendedCluster {
+
+ Connection _connection;
+
+ public CustomCluster(final LocalNode localNode, Topic dataTopic, Topic destination, Connection connection, Session session, MessageProducer producer, Timer timer, long inactiveTime) throws JMSException {
+ super(localNode, dataTopic, destination, connection, session, producer, timer, inactiveTime);
+ _connection=connection; // remember it here, we cannot fetch it from super because it is private :-(
+ }
+
+ public Destination createQueue(String name) throws JMSException {
+ return getSession().createQueue(name);
+ }
+
+ public Connection getConnection() {return _connection;}
+}
\ No newline at end of file
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomClusterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomClusterFactory.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomClusterFactory.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/CustomClusterFactory.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate.activecluster;
+
+import java.util.Timer;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.activecluster.Cluster;
+import org.activecluster.impl.DefaultCluster;
+import org.activecluster.impl.DefaultClusterFactory;
+import org.activecluster.impl.ReplicatedLocalNode;
+import org.activecluster.impl.StateService;
+import org.activecluster.impl.StateServiceStub;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class CustomClusterFactory extends DefaultClusterFactory {
+
+ protected static final Log log=LogFactory.getLog(CustomClusterFactory.class);
+
+ public CustomClusterFactory(ConnectionFactory connectionFactory) {
+ super(connectionFactory);
+ System.setProperty("activemq.broker.disable-clean-shutdown", "true");
+ }
+
+ protected Cluster createCluster(Connection connection, Session session, Topic groupDestination) throws JMSException {
+ Topic dataTopic = session.createTopic(getDataTopicPrefix() + groupDestination.getTopicName());
+
+ if ( log.isInfoEnabled() ) {
+
+ log.info("Creating cluster group producer on topic: " + groupDestination);
+ }
+
+ MessageProducer producer = createProducer(session, null);
+ producer.setDeliveryMode(getDeliveryMode());
+
+ if ( log.isInfoEnabled() ) {
+
+ log.info("Creating cluster data producer on topic: " + dataTopic);
+ }
+
+ MessageProducer keepAliveProducer = session.createProducer(dataTopic);
+ keepAliveProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ StateService serviceStub = new StateServiceStub(session, keepAliveProducer);
+
+ Destination localInbox = null;
+ if (isUseQueueForInbox()) {
+ localInbox = session.createTemporaryQueue();
+ }
+ else {
+ localInbox = session.createTemporaryTopic();
+ }
+ ReplicatedLocalNode localNode = new ReplicatedLocalNode(localInbox, serviceStub);
+ Timer timer = new Timer();
+ DefaultCluster answer = new CustomCluster(localNode, dataTopic, groupDestination, connection, session, producer, timer, getInactiveTime());
+
+// connection.setExceptionListener(new ExceptionListener() {
+
+// // could we check the exception's cause and step up the level if it is
+// // not harmless ?... - TODO
+// public void onException(JMSException e) {
+// log.trace("JMS Exception:", e);
+// }
+
+// });
+
+ return answer;
+ }
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyCluster.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyCluster.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyCluster.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyCluster.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,153 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate.activecluster;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.Map;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.ObjectMessage;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+
+import org.activecluster.ClusterListener;
+import org.activecluster.LocalNode;
+import org.activecluster.election.ElectionStrategy;
+import org.codehaus.wadi.gridstate.ExtendedCluster;
+
+public class DummyCluster implements ExtendedCluster {
+
+ public DummyCluster() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public Destination createQueue(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Topic getDestination() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Map getNodes() {
+ return Collections.EMPTY_MAP;
+ }
+
+ public void addClusterListener(ClusterListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeClusterListener(ClusterListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected final LocalNode _localNode=new DummyLocalNode();
+
+ public LocalNode getLocalNode() {
+ return _localNode;
+ }
+
+ public void send(Destination destination, Message message) {
+ // TODO Auto-generated method stub
+ }
+
+ public MessageConsumer createConsumer(Destination destination) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MessageConsumer createConsumer(Destination destination, String selector) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MessageConsumer createConsumer(Destination destination, String selector, boolean noLocal) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Message createMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public BytesMessage createBytesMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public MapMessage createMapMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ObjectMessage createObjectMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public ObjectMessage createObjectMessage(Serializable object) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public StreamMessage createStreamMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TextMessage createTextMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public TextMessage createTextMessage(String text) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean waitForClusterToComplete(int expectedCount, long timeout) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stop() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Connection getConnection() { return null; }
+
+ public void setElectionStrategy(ElectionStrategy strategy) {}
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyLocalNode.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyLocalNode.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyLocalNode.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/DummyLocalNode.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate.activecluster;
+
+import java.util.Map;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+
+import org.activecluster.LocalNode;
+
+public class DummyLocalNode implements LocalNode {
+
+ public DummyLocalNode() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public void setState(Map state) throws JMSException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Destination getDestination() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Map getState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isCoordinator() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Object getZone() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableCluster.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableCluster.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableCluster.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableCluster.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,187 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate.activecluster;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.ObjectMessage;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+
+import org.activecluster.ClusterFactory;
+import org.activecluster.ClusterListener;
+import org.activecluster.LocalNode;
+import org.activecluster.election.ElectionStrategy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.wadi.gridstate.ExtendedCluster;
+
+/**
+ * An ActiveCluster Cluster that can be re-start()-ed after a stop().
+ *
+ * @author <a href="mailto:jules@coredevelopers.net">Jules Gosnell</a>
+ * @version $Revision: 1.4 $
+ */
+public class RestartableCluster implements ExtendedCluster {
+
+ protected static final Log _log=LogFactory.getLog(RestartableCluster.class);
+
+ protected final ClusterFactory _factory;
+ protected final Topic _groupDestination;
+ protected final String _topic;
+
+ protected ExtendedCluster _cluster;
+
+ public RestartableCluster(ClusterFactory factory, Topic groupDestination) {
+ super();
+ _factory=factory;
+ _groupDestination=groupDestination;
+ _topic=null;
+ ensureCluster();
+ }
+
+ public RestartableCluster(ClusterFactory factory, String topic) {
+ super();
+ _factory=factory;
+ _groupDestination=null;
+ _topic=topic;
+ ensureCluster();
+ }
+
+ // ActiveCluster Cluster
+
+ public Topic getDestination() {
+ return _cluster.getDestination();
+ }
+
+ public Map getNodes() {
+ return _cluster.getNodes();
+ }
+
+ public void addClusterListener(ClusterListener listener) {
+ ensureCluster();
+ _cluster.addClusterListener(listener);
+ }
+
+
+ public void removeClusterListener(ClusterListener listener) {
+ ensureCluster();
+ _cluster.removeClusterListener(listener);
+ }
+
+ public LocalNode getLocalNode() {
+ return _cluster.getLocalNode();
+ }
+
+ public void send(Destination destination, Message message) throws JMSException {
+ _cluster.send(destination, message);
+ }
+
+ public MessageConsumer createConsumer(Destination destination) throws JMSException {
+ return _cluster.createConsumer(destination);
+ }
+
+ public MessageConsumer createConsumer(Destination destination, String selector) throws JMSException {
+ return _cluster.createConsumer(destination, selector);
+ }
+
+ public MessageConsumer createConsumer(Destination destination, String selector, boolean noLocal) throws JMSException {
+ return _cluster.createConsumer(destination, selector, noLocal);
+ }
+
+ public Message createMessage() throws JMSException {
+ return _cluster.createMessage();
+ }
+
+ public BytesMessage createBytesMessage() throws JMSException {
+ return _cluster.createBytesMessage();
+ }
+
+ public MapMessage createMapMessage() throws JMSException {
+ return _cluster.createMapMessage();
+ }
+
+ public ObjectMessage createObjectMessage() throws JMSException {
+ return _cluster.createObjectMessage();
+ }
+
+ public ObjectMessage createObjectMessage(Serializable object) throws JMSException {
+ return _cluster.createObjectMessage(object);
+ }
+
+ public StreamMessage createStreamMessage() throws JMSException {
+ return _cluster.createStreamMessage();
+ }
+
+ public TextMessage createTextMessage() throws JMSException {
+ return _cluster.createTextMessage();
+ }
+
+ public TextMessage createTextMessage(String text) throws JMSException {
+ return _cluster.createTextMessage(text);
+ }
+
+ public boolean waitForClusterToComplete(int expectedCount, long timeout) throws InterruptedException {
+ return _cluster.waitForClusterToComplete(expectedCount, timeout);
+ }
+
+ protected void createCluster() {
+ try {
+ if (_groupDestination!=null)
+ _cluster=(ExtendedCluster)_factory.createCluster(_groupDestination);
+ else
+ _cluster=(ExtendedCluster)_factory.createCluster(_topic);
+ } catch (Exception e) {
+ _log.error("could not start Cluster", e);
+ }
+ }
+
+ protected synchronized void ensureCluster() {
+ if (_cluster==null)
+ createCluster();
+ }
+
+ public void start() throws JMSException {
+ ensureCluster();
+ _cluster.start();
+ }
+
+ public void stop() throws JMSException {
+ _cluster.stop();
+ _cluster=null;
+ }
+
+ // ExtendedCluster
+
+ public Connection getConnection() {
+ return _cluster.getConnection();
+ }
+
+ public void setElectionStrategy(ElectionStrategy strategy) {
+ _cluster.setElectionStrategy(strategy);
+ }
+
+}
Added: incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableClusterFactory.java
URL: http://svn.apache.org/viewcvs/incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableClusterFactory.java?rev=356933&view=auto
==============================================================================
--- incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableClusterFactory.java (added)
+++ incubator/wadi/trunk/modules/core/src/main/java/org/codehaus/wadi/gridstate/activecluster/RestartableClusterFactory.java Wed Dec 14 15:32:56 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2003-2005 Core Developers Network Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codehaus.wadi.gridstate.activecluster;
+
+import javax.jms.JMSException;
+import javax.jms.Topic;
+
+import org.activecluster.Cluster;
+import org.activecluster.ClusterException;
+import org.activecluster.ClusterFactory;
+
+public class RestartableClusterFactory implements ClusterFactory {
+
+ protected final ClusterFactory _factory;
+
+ public RestartableClusterFactory(ClusterFactory factory) {
+ super();
+ _factory=factory;
+ }
+
+ public Cluster createCluster(Topic groupDestination) throws ClusterException, JMSException {
+ return new RestartableCluster(_factory, groupDestination);
+ }
+
+ public Cluster createCluster(String topic) throws ClusterException, JMSException {
+ return new RestartableCluster(_factory, topic);
+ }
+
+}