summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2013-10-07 22:23:21 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2013-10-07 22:23:21 +0000
commit5963a2d3d6860fe57afc138f095bf2d2eb5a7b80 (patch)
tree018d3d8c637e265b8292d34e5f7c11ca8ce11b7d /sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca
parent132aa8a77685ec92bc90c03f987650d275a7b639 (diff)
Official Tuscany 2.0.1 Release
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1530096 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java39
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java36
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Manageable.java31
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Status.java87
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java160
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java100
6 files changed, 0 insertions, 453 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java b/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java
deleted file mode 100644
index 8a1fab65b7..0000000000
--- a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainAssetManagerResource.java
+++ /dev/null
@@ -1,39 +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.tuscany.sca.node.manager;
-
-import java.util.List;
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-@Path("")
-public interface DomainAssetManagerResource {
-
- @GET
- @Path("{domainURI}/services/status")
- List<Status> getServiceStatus(@PathParam("domainURI") @DefaultValue("default") String domainURI);
-
-}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java b/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.java
deleted file mode 100644
index f917ca3b99..0000000000
--- a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/DomainCompositeResource.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.tuscany.sca.node.manager;
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-@Path("")
-public interface DomainCompositeResource {
-
- @GET
- @Path("{domainURI}")
- String getDomainComposite(@PathParam("domainURI") @DefaultValue("default") String domainURI);
-}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Manageable.java b/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Manageable.java
deleted file mode 100644
index 139e87c5f5..0000000000
--- a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Manageable.java
+++ /dev/null
@@ -1,31 +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.tuscany.sca.node.manager;
-
-import org.oasisopen.sca.annotation.Remotable;
-
-@Remotable
-public interface Manageable {
-
- /**
- * isAlive method that allow service to be managed
- */
- void isAlive();
-}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Status.java b/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Status.java
deleted file mode 100644
index 75d25734d8..0000000000
--- a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/Status.java
+++ /dev/null
@@ -1,87 +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.tuscany.sca.node.manager;
-
-public class Status {
- public static String OK ="ok";
- public static String WARNING = "warning";
- public static String CRITICAL = "critical";
- public static String UNAVAILABLE = "unavailable";
-
- private String name;
- private String uri;
- private String status;
- private String statusMessage;
- private long execution;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getUri() {
- return uri;
- }
-
- public void setUri(String uri) {
- this.uri = uri;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public String getStatusMessage() {
- return statusMessage;
- }
-
- public void setStatusMessage(String statusMessage) {
- this.statusMessage = statusMessage;
- }
-
- public long getExecution() {
- return execution;
- }
-
- public void setExecution(long execution) {
- this.execution = execution;
- }
-
- @Override
- public String toString() {
- return "Status [name=" + name
- + ", uri="
- + uri
- + ", status="
- + status
- + ", statusMessage="
- + statusMessage
- + ", execution="
- + execution
- + "]";
- }
-}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java
deleted file mode 100644
index 3935c75021..0000000000
--- a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainAssetManagerResourceImpl.java
+++ /dev/null
@@ -1,160 +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.tuscany.sca.node.manager.impl;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.WebApplicationException;
-
-import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.extensibility.NodeActivator;
-import org.apache.tuscany.sca.node.extensibility.NodeExtension;
-import org.apache.tuscany.sca.node.manager.DomainAssetManagerResource;
-import org.apache.tuscany.sca.node.manager.Manageable;
-import org.apache.tuscany.sca.node.manager.Status;
-import org.oasisopen.sca.annotation.Init;
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Scope;
-
-@Scope("COMPOSITE")
-public class DomainAssetManagerResourceImpl implements NodeActivator, DomainAssetManagerResource {
- private static Map<String, NodeExtension> nodeMap = new ConcurrentHashMap<String,NodeExtension>();
-
- @Property
- private int warningThreshold;
-
- @Property
- private int criticalThreshold;
-
- @Property
- private int unavailableThreshold;
-
- public void nodeStarted(Node node) {
- NodeExtension nodeExtension = (NodeExtension) node;
- nodeMap.put(nodeExtension.getDomainURI(), nodeExtension);
- }
-
- public void nodeStopped(Node node) {
- NodeExtension nodeExtension = (NodeExtension) node;
- nodeMap.remove(nodeExtension.getDomainURI());
- }
-
- @Init
- public void init() {
- System.out.println("Initializing Domain Asset Manager");
- System.out.println(" - Warning threshold : " + warningThreshold + " ms" );
- System.out.println(" - Critical threshold : " + criticalThreshold + " ms");
- System.out.println(" - Unavailable threshold : " + unavailableThreshold + " ms");
-
- }
-
- @Override
- public List<Status> getServiceStatus(@PathParam("domainURI") @DefaultValue("default") String domainURI) {
- if( ! nodeMap.containsKey(domainURI)) {
- throw new WebApplicationException(404);
- }
-
- NodeExtension node = nodeMap.get(domainURI);
- Composite domainComposite = node.getDomainComposite();
-
- List<Status> statuses = new ArrayList<Status>();
- for(Component component : domainComposite.getComponents()) {
- for(Service service : component.getServices()) {
- Interface interfaceContract = service.getInterfaceContract().getInterface();
- if(Manageable.class.getName().equals(interfaceContract.toString())) {
-
- Status status = new Status();
- status.setName(component.getName());
- status.setUri(service.getBindings().get(0).getURI());
-
- try {
- String serviceName = component.getName() + "/" + service.getName();
- Manageable serviceInstance = node.getService(Manageable.class, serviceName);
- Timer t = new Timer();
- serviceInstance.isAlive();
- status.setExecution(t.elapsed(TimeUnit.MILLISECONDS));
-
- if(status.getExecution() < warningThreshold) {
- status.setStatus(Status.OK);
- }else if(status.getExecution() > warningThreshold) {
- status.setStatus(Status.WARNING);
- }else if(status.getExecution() > criticalThreshold) {
- status.setStatus(Status.CRITICAL);
- } else {
- status.setStatus(Status.UNAVAILABLE);
- }
- } catch (Exception e) {
- status.setStatus(Status.UNAVAILABLE);
- status.setStatusMessage(e.getMessage());
- }
-
- statuses.add(status);
- }
- }
- }
-
- return statuses;
- }
-
- class Timer {
- Date time;
- long t;
-
- public Timer() {
- reset();
- }
-
- public void reset() {
- time = new Date();
- t = System.nanoTime();
- }
-
- public Date time() {
- return time;
- }
-
- public long elapsed(TimeUnit timeUnit) {
- long elapsedTime = elapsed();
- return timeUnit.convert(elapsedTime, TimeUnit.NANOSECONDS);
- }
-
- public void print(String s, TimeUnit timeUnit) {
- long elapsedTime = elapsed();
-
- System.out.println(s + ": " + timeUnit.convert(elapsedTime, TimeUnit.NANOSECONDS) + "ms");
- }
-
- private long elapsed() {
- return System.nanoTime() - t;
- }
- }
-
-}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java
deleted file mode 100644
index 9cb91e2917..0000000000
--- a/sca-java-2.x/tags/2.0.1-RC1/modules/node-manager/src/main/java/org/apache/tuscany/sca/node/manager/impl/DomainCompositeResourceImpl.java
+++ /dev/null
@@ -1,100 +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.tuscany.sca.node.manager.impl;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.ws.rs.WebApplicationException;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-
-import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.extensibility.NodeActivator;
-import org.apache.tuscany.sca.node.extensibility.NodeExtension;
-import org.apache.tuscany.sca.node.manager.DomainCompositeResource;
-
-public class DomainCompositeResourceImpl implements NodeActivator, DomainCompositeResource {
- private static Map<String, NodeExtension> nodeMap = new ConcurrentHashMap<String,NodeExtension>();
-
- public void nodeStarted(Node node) {
- NodeExtension nodeExtension = (NodeExtension) node;
- nodeMap.put(nodeExtension.getDomainURI(), nodeExtension);
- }
-
- public void nodeStopped(Node node) {
- NodeExtension nodeExtension = (NodeExtension) node;
- nodeMap.remove(nodeExtension.getDomainURI());
- }
-
- public String getDomainComposite(String domainURI) {
- if( ! nodeMap.containsKey(domainURI)) {
- throw new WebApplicationException(404);
- }
-
- NodeExtension node = nodeMap.get(domainURI);
- Composite composite = node.getDomainComposite();
-
- //set name, as it's empty by default
- composite.setName(new QName("", "Domain"));
-
- ExtensionPointRegistry registry = node.getExtensionPointRegistry();
- StAXArtifactProcessorExtensionPoint xmlProcessors =
- registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
- StAXArtifactProcessor<Composite> compositeProcessor =
- xmlProcessors.getProcessor(Composite.class);
-
- return writeComposite(composite, registry, compositeProcessor);
- }
-
-
- private String writeComposite(Composite composite, ExtensionPointRegistry registry, StAXArtifactProcessor<Composite> compositeProcessor){
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- XMLOutputFactory outputFactory =
- registry.getExtensionPoint(FactoryExtensionPoint.class)
- .getFactory(XMLOutputFactory.class);
-
- try {
- compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(registry));
- } catch(Exception ex) {
- return ex.toString();
- }
-
- String result = bos.toString();
-
- // write out and nested composites
- for (Component component : composite.getComponents()) {
- if (component.getImplementation() instanceof Composite) {
- result += "\n<!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->\n" +
- writeComposite((Composite)component.getImplementation(), registry,
- compositeProcessor);
- }
- }
- return result;
- }
-}