You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ke...@apache.org on 2012/12/14 04:32:02 UTC
[4/4] Refactor and finalize framework IPC java package structure
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportEndpointSite.java
----------------------------------------------------------------------
diff --git a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportEndpointSite.java b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportEndpointSite.java
new file mode 100644
index 0000000..e82d702
--- /dev/null
+++ b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportEndpointSite.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.transport;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TransportEndpointSite {
+ private TransportProvider _provider;
+ private TransportEndpoint _endpoint;
+ private TransportAddress _address;
+
+ private List<TransportPdu> _outputQueue = new ArrayList<TransportPdu>();
+ private Map<String, TransportMultiplexier> _multiplexierMap = new HashMap<String, TransportMultiplexier>();
+
+ private int _outstandingSignalRequests;
+
+ public TransportEndpointSite(TransportProvider provider, TransportEndpoint endpoint, TransportAddress address) {
+ assert(provider != null);
+ assert(endpoint != null);
+ assert(address != null);
+
+ _provider = provider;
+ _endpoint = endpoint;
+ _address = address;
+
+ _outstandingSignalRequests = 0;
+ }
+
+ public TransportEndpoint getEndpoint() {
+ return _endpoint;
+ }
+
+ public TransportAddress getAddress() {
+ return _address;
+ }
+
+ public void setAddress(TransportAddress address) {
+ _address = address;
+ }
+
+ public void registerMultiplexier(String name, TransportMultiplexier multiplexier) {
+ assert(name != null);
+ assert(multiplexier != null);
+ assert(_multiplexierMap.get(name) == null);
+
+ _multiplexierMap.put(name, multiplexier);
+ }
+
+ public void unregisterMultiplexier(String name) {
+ assert(name != null);
+ _multiplexierMap.remove(name);
+ }
+
+ public void addOutputPdu(TransportPdu pdu) {
+ synchronized(this) {
+ _outputQueue.add(pdu);
+ }
+
+ signalOutputProcessRequest();
+ }
+
+ public TransportPdu getNextOutputPdu() {
+ synchronized(this) {
+ if(_outputQueue.size() > 0)
+ return _outputQueue.remove(0);
+ }
+
+ return null;
+ }
+
+ public void processOutput() {
+ TransportPdu pdu;
+ TransportEndpoint endpoint = getEndpoint();
+
+ if(endpoint != null) {
+ while((pdu = getNextOutputPdu()) != null) {
+ if(pdu instanceof TransportDataPdu) {
+ String multiplexierName = ((TransportDataPdu) pdu).getMultiplexier();
+ TransportMultiplexier multiplexier = getRoutedMultiplexier(multiplexierName);
+ assert(multiplexier != null);
+ multiplexier.onTransportMessage(pdu.getSourceAddress(), pdu.getDestAddress(),
+ multiplexierName, ((TransportDataPdu) pdu).getContent());
+ }
+ }
+ }
+ }
+
+ private TransportMultiplexier getRoutedMultiplexier(String multiplexierName) {
+ TransportMultiplexier multiplexier = _multiplexierMap.get(multiplexierName);
+ if(multiplexier == null)
+ multiplexier = _endpoint;
+
+ return multiplexier;
+ }
+
+ private void signalOutputProcessRequest() {
+ boolean proceed = false;
+ synchronized(this) {
+ if(_outstandingSignalRequests == 0) {
+ _outstandingSignalRequests++;
+ proceed = true;
+ }
+ }
+
+ if(proceed)
+ _provider.requestSiteOutput(this);
+ }
+
+ public void ackOutputProcessSignal() {
+ synchronized(this) {
+ assert(_outstandingSignalRequests == 1);
+ _outstandingSignalRequests--;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportMultiplexier.java
----------------------------------------------------------------------
diff --git a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportMultiplexier.java b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportMultiplexier.java
new file mode 100644
index 0000000..b101929
--- /dev/null
+++ b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportMultiplexier.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.transport;
+
+public interface TransportMultiplexier {
+ public void onTransportMessage(String senderEndpointAddress, String targetEndpointAddress,
+ String multiplexer, String message);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportPdu.java
----------------------------------------------------------------------
diff --git a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportPdu.java b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportPdu.java
new file mode 100644
index 0000000..74238a4
--- /dev/null
+++ b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportPdu.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.transport;
+
+public class TransportPdu {
+ protected String _sourceAddress;
+ protected String _destAddress;
+
+ public TransportPdu() {
+ }
+
+ public String getSourceAddress() { return _sourceAddress; }
+ public void setSourceAddress(String sourceAddress) {
+ _sourceAddress = sourceAddress;
+ }
+
+ public String getDestAddress() {
+ return _destAddress;
+ }
+
+ public void setDestAddress(String destAddress) {
+ _destAddress = destAddress;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportProvider.java
----------------------------------------------------------------------
diff --git a/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportProvider.java b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportProvider.java
new file mode 100644
index 0000000..1283811
--- /dev/null
+++ b/framework/ipc/src/org/apache/cloudstack/framework/transport/TransportProvider.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.transport;
+
+import org.apache.cloudstack.framework.serializer.MessageSerializer;
+
+public interface TransportProvider {
+ void setMessageSerializer(MessageSerializer messageSerializer);
+ MessageSerializer getMessageSerializer();
+
+ TransportEndpointSite attach(TransportEndpoint endpoint, String predefinedAddress);
+ boolean detach(TransportEndpoint endpoint);
+
+ void requestSiteOutput(TransportEndpointSite site);
+
+ void sendMessage(String soureEndpointAddress, String targetEndpointAddress,
+ String multiplexier, String message);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java
new file mode 100644
index 0000000..71afd10
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleCallee.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.codestyle;
+
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+public class AsyncSampleCallee {
+ AsyncSampleCallee _driver;
+
+ public void createVolume(Object realParam, AsyncCompletionCallback<String> callback) {
+
+ // async executed logic
+ {
+
+ String resultObject = new String();
+ callback.complete(resultObject);
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java
new file mode 100644
index 0000000..4ce86c6
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleEventDrivenStyleCaller.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.codestyle;
+
+import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
+import org.apache.cloudstack.framework.async.AsyncCallbackDriver;
+import org.apache.cloudstack.framework.async.AsyncCallbackHandler;
+
+public class AsyncSampleEventDrivenStyleCaller {
+ AsyncSampleCallee _ds = new AsyncSampleCallee();
+ AsyncCallbackDriver _callbackDriver;
+
+ public void MethodThatWillCallAsyncMethod() {
+ Object vol = new Object();
+ _ds.createVolume(vol,
+ new AsyncCallbackDispatcher(this)
+ .setOperationName("volume.create")
+ .setContextParam("origVolume", vol)
+ );
+ }
+
+ @AsyncCallbackHandler(operationName="volume.create")
+ public void HandleVolumeCreateAsyncCallback(AsyncCallbackDispatcher callback) {
+ Object origVol = callback.getContextParam("origVolume");
+
+ Object resultVol = callback.getResult();
+ }
+
+ public static void main(String[] args) {
+ AsyncSampleEventDrivenStyleCaller caller = new AsyncSampleEventDrivenStyleCaller();
+ caller.MethodThatWillCallAsyncMethod();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java
new file mode 100644
index 0000000..e4e7af8
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/AsyncSampleListenerStyleCaller.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.codestyle;
+
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+
+public class AsyncSampleListenerStyleCaller {
+ AsyncSampleCallee _ds;
+
+ public void MethodThatWillCallAsyncMethod() {
+ String vol = new String();
+
+ _ds.createVolume(vol,
+ new AsyncCompletionCallback<String>() {
+ @Override
+ public void complete(String resultObject) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java
new file mode 100644
index 0000000..a6c8105
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyEventDrivenStyle.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.codestyle;
+
+import org.apache.cloudstack.framework.rpc.RpcCallbackHandler;
+import org.apache.cloudstack.framework.rpc.RpcClientCall;
+import org.apache.cloudstack.framework.rpc.RpcException;
+import org.apache.cloudstack.framework.rpc.RpcIOException;
+import org.apache.cloudstack.framework.rpc.RpcProvider;
+import org.apache.cloudstack.framework.rpc.RpcTimeoutException;
+
+public class ClientOnlyEventDrivenStyle {
+ RpcProvider _rpcProvider;
+
+ public void AsyncCallRpcService() {
+ String cmd = new String();
+ _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000)
+ .setCallbackDispatcherTarget(this)
+ .setContextParam("origCmd", cmd) // save context object for callback handler
+ .apply();
+ }
+
+ @RpcCallbackHandler(command="TestCommand")
+ public void OnAsyncCallRpcServiceCallback(RpcClientCall call) {
+ try {
+ String origCmd = call.getContextParam("origCmd"); // restore calling context at callback handler
+
+ String answer = call.get();
+
+ } catch(RpcTimeoutException e) {
+
+ } catch(RpcIOException e) {
+
+ } catch(RpcException e) {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyListenerStyle.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyListenerStyle.java b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyListenerStyle.java
new file mode 100644
index 0000000..2d79555
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/codestyle/ClientOnlyListenerStyle.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.codestyle;
+
+import org.apache.cloudstack.framework.rpc.RpcCallbackListener;
+import org.apache.cloudstack.framework.rpc.RpcClientCall;
+import org.apache.cloudstack.framework.rpc.RpcException;
+import org.apache.cloudstack.framework.rpc.RpcIOException;
+import org.apache.cloudstack.framework.rpc.RpcProvider;
+import org.apache.cloudstack.framework.rpc.RpcTimeoutException;
+
+public class ClientOnlyListenerStyle {
+
+ RpcProvider _rpcProvider;
+
+ public void AsyncCallRpcService() {
+ String cmd = new String();
+ _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000)
+ .addCallbackListener(new RpcCallbackListener<String>() {
+ @Override
+ public void onSuccess(String result) {
+ }
+
+ @Override
+ public void onFailure(RpcException e) {
+ }
+ }).apply();
+ }
+
+ public void SyncCallRpcService() {
+ String cmd = new String();
+ RpcClientCall call = _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000).apply();
+
+ try {
+ String answer = call.get();
+ } catch (RpcTimeoutException e) {
+
+ } catch (RpcIOException e) {
+
+ } catch (RpcException e) {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleCallee.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleCallee.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleCallee.java
deleted file mode 100644
index 62d03f8..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleCallee.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-public class AsyncSampleCallee {
- AsyncSampleCallee _driver;
-
- public void createVolume(Object realParam, AsyncCompletionCallback<TestVolume> callback) {
-
- // async executed logic
- {
-
- TestVolume resultObject = new TestVolume();
- callback.complete(resultObject);
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleEventDrivenStyleCaller.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleEventDrivenStyleCaller.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleEventDrivenStyleCaller.java
deleted file mode 100644
index c0818db..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleEventDrivenStyleCaller.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-public class AsyncSampleEventDrivenStyleCaller {
- AsyncSampleCallee _ds = new AsyncSampleCallee();
- AsyncCallbackDriver _callbackDriver;
-
- public void MethodThatWillCallAsyncMethod() {
- TestVolume vol = new TestVolume();
- _ds.createVolume(vol,
- new AsyncCallbackDispatcher(this)
- .setOperationName("volume.create")
- .setContextParam("origVolume", vol)
- );
- }
-
- @AsyncCallbackHandler(operationName="volume.create")
- public void HandleVolumeCreateAsyncCallback(AsyncCallbackDispatcher callback) {
- TestVolume origVol = callback.getContextParam("origVolume");
-
- TestVolume resultVol = callback.getResult();
- }
-
- public static void main(String[] args) {
- AsyncSampleEventDrivenStyleCaller caller = new AsyncSampleEventDrivenStyleCaller();
- caller.MethodThatWillCallAsyncMethod();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleListenerStyleCaller.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleListenerStyleCaller.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleListenerStyleCaller.java
deleted file mode 100644
index ec3d9b1..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/AsyncSampleListenerStyleCaller.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-public class AsyncSampleListenerStyleCaller {
- AsyncSampleCallee _ds;
-
- public void MethodThatWillCallAsyncMethod() {
- TestVolume vol = new TestVolume();
-
- _ds.createVolume(vol,
- new AsyncCompletionCallback<TestVolume>() {
- @Override
- public void complete(TestVolume resultObject) {
- // TODO Auto-generated method stub
-
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyEventDrivenStyle.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyEventDrivenStyle.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyEventDrivenStyle.java
deleted file mode 100644
index 37c78ba..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyEventDrivenStyle.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-public class ClientOnlyEventDrivenStyle {
- RpcProvider _rpcProvider;
-
- public void AsyncCallRpcService() {
- TestCommand cmd = new TestCommand();
- _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000)
- .setCallbackDispatcherTarget(this)
- .setContextParam("origCmd", cmd) // save context object for callback handler
- .apply();
- }
-
- @RpcCallbackHandler(command="TestCommand")
- public void OnAsyncCallRpcServiceCallback(RpcClientCall call) {
- try {
- TestCommand origCmd = call.getContextParam("origCmd"); // restore calling context at callback handler
-
- TestCommandAnswer answer = call.get();
-
- } catch(RpcTimeoutException e) {
-
- } catch(RpcIOException e) {
-
- } catch(RpcException e) {
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyListenerStyle.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyListenerStyle.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyListenerStyle.java
deleted file mode 100644
index b1f9166..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/ClientOnlyListenerStyle.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-public class ClientOnlyListenerStyle {
-
- RpcProvider _rpcProvider;
-
- public void AsyncCallRpcService() {
- TestCommand cmd = new TestCommand();
- _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000)
- .addCallbackListener(new RpcCallbackListener<TestCommandAnswer>() {
- @Override
- public void onSuccess(TestCommandAnswer result) {
- }
-
- @Override
- public void onFailure(RpcException e) {
- }
- }).apply();
- }
-
- public void SyncCallRpcService() {
- TestCommand cmd = new TestCommand();
- RpcClientCall call = _rpcProvider.newCall("host-2").setCommand("TestCommand").setCommandArg(cmd).setTimeout(10000).apply();
-
- try {
- TestCommandAnswer answer = call.get();
- } catch (RpcTimeoutException e) {
-
- } catch (RpcIOException e) {
-
- } catch (RpcException e) {
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/SampleComponent.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/SampleComponent.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/SampleComponent.java
deleted file mode 100644
index 25d3452..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/SampleComponent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-public class SampleComponent {
-
- RpcProvider _rpcProvider;
- EventBus _eventBus;
-
- public SampleComponent() {
- }
-
- public void init() {
-
- _rpcProvider.registerRpcServiceEndpoint(
- RpcServiceDispatcher.getDispatcher(this));
-
- // subscribe to all network events (for example)
- _eventBus.subscribe("network",
- EventDispatcher.getDispatcher(this));
- }
-
- @RpcServiceHandler(command="StartCommand")
- void onStartCommand(RpcServerCall call) {
- call.completeCall("Call response");
- }
-
- @EventHandler(topic="network.prepare")
- void onPrepareNetwork(String sender, String topic, Object args) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommand.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommand.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommand.java
deleted file mode 100644
index abceb4e..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommand.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-@OnwireName(name="TestCommand")
-public class TestCommand {
- public TestCommand() {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommandAnswer.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommandAnswer.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommandAnswer.java
deleted file mode 100644
index 550333b..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestCommandAnswer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging;
-
-@OnwireName(name="TestCommandAnswer")
-public class TestCommandAnswer {
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestVolume.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestVolume.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestVolume.java
deleted file mode 100644
index 3001ee5..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/TestVolume.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.apache.cloudstack.framework.messaging;
-
-public class TestVolume {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServer.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServer.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServer.java
deleted file mode 100644
index aeb3b1c..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging.server;
-
-import org.springframework.stereotype.Component;
-
-@Component
-public class SampleManagementServer {
-
- public void mainLoop() {
- while(true) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServerApp.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServerApp.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServerApp.java
deleted file mode 100644
index 2748e7f..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagementServerApp.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging.server;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.apache.log4j.xml.DOMConfigurator;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class SampleManagementServerApp {
-
- private static void setupLog4j() {
- URL configUrl = System.class.getResource("/resources/log4j-cloud.xml");
- if(configUrl != null) {
- System.out.println("Configure log4j using log4j-cloud.xml");
-
- try {
- File file = new File(configUrl.toURI());
-
- System.out.println("Log4j configuration from : " + file.getAbsolutePath());
- DOMConfigurator.configureAndWatch(file.getAbsolutePath(), 10000);
- } catch (URISyntaxException e) {
- System.out.println("Unable to convert log4j configuration Url to URI");
- }
- } else {
- System.out.println("Configure log4j with default properties");
- }
- }
-
- public static void main(String args[]) {
- setupLog4j();
-
- ApplicationContext context = new ClassPathXmlApplicationContext("/resources/SampleManagementServerAppContext.xml");
- SampleManagementServer server = context.getBean(SampleManagementServer.class);
- server.mainLoop();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent.java
deleted file mode 100644
index 8600a4d..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging.server;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.framework.messaging.EventBus;
-import org.apache.cloudstack.framework.messaging.EventDispatcher;
-import org.apache.cloudstack.framework.messaging.EventHandler;
-import org.apache.cloudstack.framework.messaging.RpcCallbackListener;
-import org.apache.cloudstack.framework.messaging.RpcException;
-import org.apache.cloudstack.framework.messaging.RpcProvider;
-import org.apache.cloudstack.framework.messaging.RpcServerCall;
-import org.apache.cloudstack.framework.messaging.RpcServiceDispatcher;
-import org.apache.cloudstack.framework.messaging.RpcServiceHandler;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SampleManagerComponent {
- private static final Logger s_logger = Logger.getLogger(SampleManagerComponent.class);
-
- @Inject
- private EventBus _eventBus;
-
- @Inject
- private RpcProvider _rpcProvider;
-
- private Timer _timer = new Timer();
-
- public SampleManagerComponent() {
- }
-
- @PostConstruct
- public void init() {
- _rpcProvider.registerRpcServiceEndpoint(
- RpcServiceDispatcher.getDispatcher(this));
-
- // subscribe to all network events (for example)
- _eventBus.subscribe("network",
- EventDispatcher.getDispatcher(this));
-
- _timer.schedule(new TimerTask() {
- public void run() {
- testRpc();
- }
- }, 3000);
- }
-
- @RpcServiceHandler(command="NetworkPrepare")
- void onStartCommand(RpcServerCall call) {
- call.completeCall("NetworkPrepare completed");
- }
-
- @EventHandler(topic="network.prepare")
- void onPrepareNetwork(String sender, String topic, Object args) {
- }
-
- void testRpc() {
- SampleStoragePrepareCommand cmd = new SampleStoragePrepareCommand();
- cmd.setStoragePool("Pool1");
- cmd.setVolumeId("vol1");
-
- _rpcProvider.newCall()
- .setCommand("StoragePrepare").setCommandArg(cmd).setTimeout(10000)
- .addCallbackListener(new RpcCallbackListener<SampleStoragePrepareAnswer>() {
- @Override
- public void onSuccess(SampleStoragePrepareAnswer result) {
- s_logger.info("StoragePrepare return result: " + result.getResult());
- }
-
- @Override
- public void onFailure(RpcException e) {
- s_logger.info("StoragePrepare failed");
- }
- }).apply();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent2.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent2.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent2.java
deleted file mode 100644
index e2259d3..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleManagerComponent2.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging.server;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.framework.messaging.EventBus;
-import org.apache.cloudstack.framework.messaging.EventDispatcher;
-import org.apache.cloudstack.framework.messaging.EventHandler;
-import org.apache.cloudstack.framework.messaging.RpcProvider;
-import org.apache.cloudstack.framework.messaging.RpcServerCall;
-import org.apache.cloudstack.framework.messaging.RpcServiceDispatcher;
-import org.apache.cloudstack.framework.messaging.RpcServiceHandler;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-@Component
-public class SampleManagerComponent2 {
- private static final Logger s_logger = Logger.getLogger(SampleManagerComponent2.class);
-
- @Inject
- private EventBus _eventBus;
-
- @Inject
- private RpcProvider _rpcProvider;
-
- public SampleManagerComponent2() {
- }
-
- @PostConstruct
- public void init() {
- _rpcProvider.registerRpcServiceEndpoint(
- RpcServiceDispatcher.getDispatcher(this));
-
- // subscribe to all network events (for example)
- _eventBus.subscribe("storage",
- EventDispatcher.getDispatcher(this));
- }
-
- @RpcServiceHandler(command="StoragePrepare")
- void onStartCommand(RpcServerCall call) {
- s_logger.info("Reevieved StoragePrpare call");
- SampleStoragePrepareCommand cmd = call.getCommandArgument();
-
- s_logger.info("StoragePrepare command arg. pool: " + cmd.getStoragePool() + ", vol: " + cmd.getVolumeId());
- SampleStoragePrepareAnswer answer = new SampleStoragePrepareAnswer();
- answer.setResult("Successfully executed StoragePrepare command");
-
- call.completeCall(answer);
- }
-
- @EventHandler(topic="storage.prepare")
- void onPrepareNetwork(String sender, String topic, Object args) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareAnswer.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareAnswer.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareAnswer.java
deleted file mode 100644
index ccc1cbe..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareAnswer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging.server;
-
-import org.apache.cloudstack.framework.messaging.OnwireName;
-
-@OnwireName(name="SampleStoragePrepareAnswer")
-public class SampleStoragePrepareAnswer {
- String result;
-
- public SampleStoragePrepareAnswer() {
- }
-
- public String getResult() {
- return result;
- }
-
- public void setResult(String result) {
- this.result = result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareCommand.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareCommand.java b/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareCommand.java
deleted file mode 100644
index c7ce1cd..0000000
--- a/framework/ipc/test/org/apache/cloudstack/framework/messaging/server/SampleStoragePrepareCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.cloudstack.framework.messaging.server;
-
-import org.apache.cloudstack.framework.messaging.OnwireName;
-
-@OnwireName(name="SampleStoragePrepareCommand")
-public class SampleStoragePrepareCommand {
-
- String storagePool;
- String volumeId;
-
- public SampleStoragePrepareCommand() {
- }
-
- public String getStoragePool() {
- return storagePool;
- }
-
- public void setStoragePool(String storagePool) {
- this.storagePool = storagePool;
- }
-
- public String getVolumeId() {
- return volumeId;
- }
-
- public void setVolumeId(String volumeId) {
- this.volumeId = volumeId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServer.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServer.java b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServer.java
new file mode 100644
index 0000000..2a168ac
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServer.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.sampleserver;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class SampleManagementServer {
+
+ public void mainLoop() {
+ while(true) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServerApp.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServerApp.java b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServerApp.java
new file mode 100644
index 0000000..a9479f3
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagementServerApp.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.sampleserver;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.log4j.xml.DOMConfigurator;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SampleManagementServerApp {
+
+ private static void setupLog4j() {
+ URL configUrl = System.class.getResource("/resources/log4j-cloud.xml");
+ if(configUrl != null) {
+ System.out.println("Configure log4j using log4j-cloud.xml");
+
+ try {
+ File file = new File(configUrl.toURI());
+
+ System.out.println("Log4j configuration from : " + file.getAbsolutePath());
+ DOMConfigurator.configureAndWatch(file.getAbsolutePath(), 10000);
+ } catch (URISyntaxException e) {
+ System.out.println("Unable to convert log4j configuration Url to URI");
+ }
+ } else {
+ System.out.println("Configure log4j with default properties");
+ }
+ }
+
+ public static void main(String args[]) {
+ setupLog4j();
+
+ ApplicationContext context = new ClassPathXmlApplicationContext("/resources/SampleManagementServerAppContext.xml");
+ SampleManagementServer server = context.getBean(SampleManagementServer.class);
+ server.mainLoop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent.java b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent.java
new file mode 100644
index 0000000..7b0a2ec
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.sampleserver;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.framework.eventbus.EventBus;
+import org.apache.cloudstack.framework.eventbus.EventDispatcher;
+import org.apache.cloudstack.framework.eventbus.EventHandler;
+import org.apache.cloudstack.framework.rpc.RpcCallbackListener;
+import org.apache.cloudstack.framework.rpc.RpcException;
+import org.apache.cloudstack.framework.rpc.RpcProvider;
+import org.apache.cloudstack.framework.rpc.RpcServerCall;
+import org.apache.cloudstack.framework.rpc.RpcServiceDispatcher;
+import org.apache.cloudstack.framework.rpc.RpcServiceHandler;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SampleManagerComponent {
+ private static final Logger s_logger = Logger.getLogger(SampleManagerComponent.class);
+
+ @Inject
+ private EventBus _eventBus;
+
+ @Inject
+ private RpcProvider _rpcProvider;
+
+ private Timer _timer = new Timer();
+
+ public SampleManagerComponent() {
+ }
+
+ @PostConstruct
+ public void init() {
+ _rpcProvider.registerRpcServiceEndpoint(
+ RpcServiceDispatcher.getDispatcher(this));
+
+ // subscribe to all network events (for example)
+ _eventBus.subscribe("network",
+ EventDispatcher.getDispatcher(this));
+
+ _timer.schedule(new TimerTask() {
+ public void run() {
+ testRpc();
+ }
+ }, 3000);
+ }
+
+ @RpcServiceHandler(command="NetworkPrepare")
+ void onStartCommand(RpcServerCall call) {
+ call.completeCall("NetworkPrepare completed");
+ }
+
+ @EventHandler(topic="network.prepare")
+ void onPrepareNetwork(String sender, String topic, Object args) {
+ }
+
+ void testRpc() {
+ SampleStoragePrepareCommand cmd = new SampleStoragePrepareCommand();
+ cmd.setStoragePool("Pool1");
+ cmd.setVolumeId("vol1");
+
+ _rpcProvider.newCall()
+ .setCommand("StoragePrepare").setCommandArg(cmd).setTimeout(10000)
+ .addCallbackListener(new RpcCallbackListener<SampleStoragePrepareAnswer>() {
+ @Override
+ public void onSuccess(SampleStoragePrepareAnswer result) {
+ s_logger.info("StoragePrepare return result: " + result.getResult());
+ }
+
+ @Override
+ public void onFailure(RpcException e) {
+ s_logger.info("StoragePrepare failed");
+ }
+ }).apply();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent2.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent2.java b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent2.java
new file mode 100644
index 0000000..9fa06f5
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleManagerComponent2.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.sampleserver;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.framework.eventbus.EventBus;
+import org.apache.cloudstack.framework.eventbus.EventDispatcher;
+import org.apache.cloudstack.framework.eventbus.EventHandler;
+import org.apache.cloudstack.framework.rpc.RpcProvider;
+import org.apache.cloudstack.framework.rpc.RpcServerCall;
+import org.apache.cloudstack.framework.rpc.RpcServiceDispatcher;
+import org.apache.cloudstack.framework.rpc.RpcServiceHandler;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SampleManagerComponent2 {
+ private static final Logger s_logger = Logger.getLogger(SampleManagerComponent2.class);
+
+ @Inject
+ private EventBus _eventBus;
+
+ @Inject
+ private RpcProvider _rpcProvider;
+
+ public SampleManagerComponent2() {
+ }
+
+ @PostConstruct
+ public void init() {
+ _rpcProvider.registerRpcServiceEndpoint(
+ RpcServiceDispatcher.getDispatcher(this));
+
+ // subscribe to all network events (for example)
+ _eventBus.subscribe("storage",
+ EventDispatcher.getDispatcher(this));
+ }
+
+ @RpcServiceHandler(command="StoragePrepare")
+ void onStartCommand(RpcServerCall call) {
+ s_logger.info("Reevieved StoragePrpare call");
+ SampleStoragePrepareCommand cmd = call.getCommandArgument();
+
+ s_logger.info("StoragePrepare command arg. pool: " + cmd.getStoragePool() + ", vol: " + cmd.getVolumeId());
+ SampleStoragePrepareAnswer answer = new SampleStoragePrepareAnswer();
+ answer.setResult("Successfully executed StoragePrepare command");
+
+ call.completeCall(answer);
+ }
+
+ @EventHandler(topic="storage.prepare")
+ void onPrepareNetwork(String sender, String topic, Object args) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareAnswer.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareAnswer.java b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareAnswer.java
new file mode 100644
index 0000000..19a39e1
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareAnswer.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.sampleserver;
+
+import org.apache.cloudstack.framework.serializer.OnwireName;
+
+@OnwireName(name="SampleStoragePrepareAnswer")
+public class SampleStoragePrepareAnswer {
+ String result;
+
+ public SampleStoragePrepareAnswer() {
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareCommand.java
----------------------------------------------------------------------
diff --git a/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareCommand.java b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareCommand.java
new file mode 100644
index 0000000..8413522
--- /dev/null
+++ b/framework/ipc/test/org/apache/cloudstack/framework/sampleserver/SampleStoragePrepareCommand.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cloudstack.framework.sampleserver;
+
+import org.apache.cloudstack.framework.serializer.OnwireName;
+
+@OnwireName(name="SampleStoragePrepareCommand")
+public class SampleStoragePrepareCommand {
+
+ String storagePool;
+ String volumeId;
+
+ public SampleStoragePrepareCommand() {
+ }
+
+ public String getStoragePool() {
+ return storagePool;
+ }
+
+ public void setStoragePool(String storagePool) {
+ this.storagePool = storagePool;
+ }
+
+ public String getVolumeId() {
+ return volumeId;
+ }
+
+ public void setVolumeId(String volumeId) {
+ this.volumeId = volumeId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/01a4a51a/framework/ipc/test/resources/SampleManagementServerAppContext.xml
----------------------------------------------------------------------
diff --git a/framework/ipc/test/resources/SampleManagementServerAppContext.xml b/framework/ipc/test/resources/SampleManagementServerAppContext.xml
index 9709f2f..4d5e044 100644
--- a/framework/ipc/test/resources/SampleManagementServerAppContext.xml
+++ b/framework/ipc/test/resources/SampleManagementServerAppContext.xml
@@ -16,30 +16,30 @@
<context:annotation-config />
<context:component-scan base-package="org.apache.cloudstack, com.cloud" />
- <bean id="onwireRegistry" class="org.apache.cloudstack.framework.messaging.OnwireClassRegistry"
+ <bean id="onwireRegistry" class="org.apache.cloudstack.framework.serializer.OnwireClassRegistry"
init-method="scan" >
<property name="packages">
<list>
- <value>org.apache.cloudstack.framework.messaging</value>
+ <value>org.apache.cloudstack.framework</value>
</list>
</property>
</bean>
- <bean id="messageSerializer" class="org.apache.cloudstack.framework.messaging.JsonMessageSerializer">
+ <bean id="messageSerializer" class="org.apache.cloudstack.framework.serializer.JsonMessageSerializer">
<property name="onwireClassRegistry" ref="onwireRegistry" />
</bean>
- <bean id="transportProvider" class="org.apache.cloudstack.framework.messaging.server.ServerTransportProvider" init-method="initialize">
+ <bean id="transportProvider" class="org.apache.cloudstack.framework.server.ServerTransportProvider" init-method="initialize">
<property name="workerPoolSize" value="5" />
<property name="nodeId" value="Node1" />
<property name="messageSerializer" ref="messageSerializer" />
</bean>
- <bean id="rpcProvider" class="org.apache.cloudstack.framework.messaging.RpcProviderImpl" init-method="initialize">
+ <bean id="rpcProvider" class="org.apache.cloudstack.framework.rpc.RpcProviderImpl" init-method="initialize">
<constructor-arg ref="transportProvider" />
<property name="messageSerializer" ref="messageSerializer" />
</bean>
- <bean id="eventBus" class = "org.apache.cloudstack.framework.messaging.EventBusBase" />
+ <bean id="eventBus" class = "org.apache.cloudstack.framework.eventbus.EventBusBase" />
</beans>