Author: mattmann
Date: Tue Feb 15 22:53:22 2011
New Revision: 1071097
URL: http://svn.apache.org/viewvc?rev=1071097&view=rev
Log:
- progress towards OODT-139 PCS JAX-RS services: Health Monitor. Thanks to
ahart and pramirez for testing.
Added:
oodt/trunk/pcs/services/ (with props)
oodt/trunk/pcs/services/src/
oodt/trunk/pcs/services/src/main/
oodt/trunk/pcs/services/src/main/java/
oodt/trunk/pcs/services/src/main/java/org/
oodt/trunk/pcs/services/src/main/java/org/apache/
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java
(with props)
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSService.java
(with props)
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfMetKeys.java
(with props)
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfig.java
(with props)
oodt/trunk/pcs/services/src/main/webapp/
oodt/trunk/pcs/services/src/main/webapp/META-INF/
oodt/trunk/pcs/services/src/main/webapp/META-INF/context.xml
oodt/trunk/pcs/services/src/main/webapp/WEB-INF/
oodt/trunk/pcs/services/src/main/webapp/WEB-INF/web.xml
Modified:
oodt/trunk/pcs/core/src/main/resources/pcs.logging.properties
Modified: oodt/trunk/pcs/core/src/main/resources/pcs.logging.properties
URL:
http://svn.apache.org/viewvc/oodt/trunk/pcs/core/src/main/resources/pcs.logging.properties?rev=1071097&r1=1071096&r2=1071097&view=diff
==============================================================================
--- oodt/trunk/pcs/core/src/main/resources/pcs.logging.properties (original)
+++ oodt/trunk/pcs/core/src/main/resources/pcs.logging.properties Tue Feb 15
22:53:22 2011
@@ -44,4 +44,5 @@ org.apache.oodt.cas.workflow.instrepo.le
org.apache.commons.httpclient.level = OFF
httpclient.wire.header.level = OFF
httpclient.wire.level = OFF
+sun.net.www.protocol.http.level = OFF
Propchange: oodt/trunk/pcs/services/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Feb 15 22:53:22 2011
@@ -0,0 +1 @@
+target
Added:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java?rev=1071097&view=auto
==============================================================================
---
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java
(added)
+++
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java
Tue Feb 15 22:53:22 2011
@@ -0,0 +1,419 @@
+/**
+ * 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.oodt.pcs.services;
+
+//JDK imports
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//JAX-RS imports
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+//JSON imports
+import net.sf.json.JSONObject;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.metadata.CoreMetKeys;
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.pcs.health.CrawlerHealth;
+import org.apache.oodt.pcs.health.CrawlerStatus;
+import org.apache.oodt.pcs.health.JobHealthStatus;
+import org.apache.oodt.pcs.health.PCSDaemonStatus;
+import org.apache.oodt.pcs.health.PCSHealthMonitorMetKeys;
+import org.apache.oodt.pcs.health.PCSHealthMonitorReport;
+import org.apache.oodt.pcs.tools.PCSHealthMonitor;
+import org.apache.oodt.pcs.util.FileManagerUtils;
+
+/**
+ *
+ * The JAX-RS resource exposing the {@link PCSHealthMonitor}.
+ *
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+@Path("health")
+public class HealthResource extends PCSService {
+
+ private static final long serialVersionUID = -7768836001459227323L;
+
+ private static final Logger LOG = Logger.getLogger(HealthResource.class
+ .getName());
+
+ private PCSHealthMonitor mon;
+
+ public HealthResource() throws MalformedURLException, InstantiationException
{
+ super();
+ mon = new PCSHealthMonitor(PCSService.conf.getFmUrl().toString(),
+ PCSService.conf.getWmUrl().toString(), PCSService.conf.getRmUrl()
+ .toString(), PCSService.conf.getCrawlerConfigFilePath(),
+ PCSService.conf.getWorkflowStatusesFilePath());
+ }
+
+ @GET
+ @Path("report")
+ @Produces("text/plain")
+ public String healthReport() {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ Map<String, Object> daemonOutput = new HashMap<String, Object>();
+ daemonOutput.put("fm", this.encodeDaemonStatus(report.getFmStatus()));
+ daemonOutput.put("wm", this.encodeDaemonStatus(report.getWmStatus()));
+ daemonOutput.put("rm", this.encodeDaemonStatus(report.getRmStatus()));
+ if (report.getRmStatus().getStatus().equals(
+ PCSHealthMonitorMetKeys.STATUS_UP)) {
+ // print out the batch stubs
+ List<Object> stubs = new Vector<Object>();
+ for (PCSDaemonStatus bStatus : (List<PCSDaemonStatus>) (List<?>) report
+ .getBatchStubStatus()) {
+ stubs.add(this.encodeDaemonStatus(bStatus));
+ }
+ daemonOutput.put("stubs", stubs);
+ }
+ Map<String, Object> crawlerOutput = new HashMap<String, Object>();
+ for (CrawlerStatus cs : (List<CrawlerStatus>) (List<?>) report
+ .getCrawlerStatus()) {
+ crawlerOutput.put(cs.getInfo().getCrawlerName(), this
+ .encodeCrawlerStatus(cs));
+ }
+ Map<String, Object> latestFilesOutput = new HashMap<String, Object>();
+ latestFilesOutput.put("topN", PCSHealthMonitor.TOP_N_PRODUCTS);
+ List<Object> latestFilesList = new Vector<Object>();
+ for (Product prod : (List<Product>) (List<?>) report
+ .getLatestProductsIngested()) {
+ try {
+ this.encodeLatestFile(latestFilesList, prod);
+ } catch (MalformedURLException e) {
+ LOG.log(Level.WARNING, "Unable to encode latest file: ["
+ + prod.getProductName() + "]: error: Message: " + e.getMessage());
+ }
+ }
+ latestFilesOutput.put("files", latestFilesList);
+ List<Object> jobStatusList = new Vector<Object>();
+ for (JobHealthStatus js : (List<JobHealthStatus>) (List<?>) report
+ .getJobHealthStatus()) {
+ jobStatusList.add(this.encodeJobStatus(js));
+ }
+
+ List<Object> crawlerHealthList = new Vector<Object>();
+ for (CrawlerHealth ch : (List<CrawlerHealth>) (List<?>) report
+ .getCrawlerHealthStatus()) {
+ crawlerHealthList.add(this.encodeCrawlerHealth(ch));
+ }
+
+ output.put("daemonStatus", daemonOutput);
+ output.put("crawlerStatus", crawlerOutput);
+ output.put("latestFiles", latestFilesOutput);
+ output.put("jobHealth", jobStatusList);
+ output.put("ingestHealth", crawlerHealthList);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/ingest")
+ @Produces("text/plain")
+ public String ingestReport() {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ List<Object> crawlerHealthList = new Vector<Object>();
+ for (CrawlerHealth ch : (List<CrawlerHealth>) (List<?>) report
+ .getCrawlerHealthStatus()) {
+ crawlerHealthList.add(this.encodeCrawlerHealth(ch));
+ }
+ output.put("ingestHealth", crawlerHealthList);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/ingest/{cname}")
+ @Produces("text/plain")
+ public String ingestReportByName(@PathParam("cname") String crawlerName) {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ List<Object> crawlerHealthList = new Vector<Object>();
+ boolean found = false;
+ for (CrawlerHealth ch : (List<CrawlerHealth>) (List<?>) report
+ .getCrawlerHealthStatus()) {
+ if (ch.getCrawlerName().equals(crawlerName)) {
+ crawlerHealthList.add(this.encodeCrawlerHealth(ch));
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ throw new ResourceNotFoundException(
+ "No ingest crawler found with name: [" + crawlerName + "]");
+ output.put("ingestHealth", crawlerHealthList);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/jobs")
+ @Produces("text/plain")
+ public String jobsReport() {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ List<Object> jobStatusList = new Vector<Object>();
+ for (JobHealthStatus js : (List<JobHealthStatus>) (List<?>) report
+ .getJobHealthStatus()) {
+ jobStatusList.add(this.encodeJobStatus(js));
+ }
+ output.put("jobHealth", jobStatusList);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/jobs/{state}")
+ @Produces("text/plain")
+ public String jobsReportByState(@PathParam("state") String jobState) {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ List<Object> jobStatusList = new Vector<Object>();
+ boolean found = false;
+ for (JobHealthStatus js : (List<JobHealthStatus>) (List<?>) report
+ .getJobHealthStatus()) {
+ if (js.getStatus().equals(jobState)) {
+ jobStatusList.add(this.encodeJobStatus(js));
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ throw new ResourceNotFoundException(
+ "Unable to find any jobs with associated state: [" + jobState + "]");
+ output.put("jobHealth", jobStatusList);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/daemon")
+ @Produces("text/plain")
+ public String daemonReport() {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ Map<String, Object> daemonOutput = new HashMap<String, Object>();
+ daemonOutput.put("fm", this.encodeDaemonStatus(report.getFmStatus()));
+ daemonOutput.put("wm", this.encodeDaemonStatus(report.getWmStatus()));
+ daemonOutput.put("rm", this.encodeDaemonStatus(report.getRmStatus()));
+ if (report.getRmStatus().getStatus().equals(
+ PCSHealthMonitorMetKeys.STATUS_UP)) {
+ // print out the batch stubs
+ List<Object> stubs = new Vector<Object>();
+ for (PCSDaemonStatus bStatus : (List<PCSDaemonStatus>) (List<?>) report
+ .getBatchStubStatus()) {
+ stubs.add(this.encodeDaemonStatus(bStatus));
+ }
+ daemonOutput.put("stubs", stubs);
+ }
+ output.put("daemonStatus", daemonOutput);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/daemon/{dname}")
+ @Produces("text/plain")
+ public String daemonReportByName(@PathParam("dname") String daemonName) {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ Map<String, Object> daemonOutput = new HashMap<String, Object>();
+ if (daemonName.equals("fm")) {
+ daemonOutput.put("fm", this.encodeDaemonStatus(report.getFmStatus()));
+ } else if (daemonName.equals("wm")) {
+ daemonOutput.put("wm", this.encodeDaemonStatus(report.getWmStatus()));
+ } else if (daemonName.equals("rm")) {
+ daemonOutput.put("rm", this.encodeDaemonStatus(report.getRmStatus()));
+ } else if (daemonName.equals("stubs")) {
+ if (report.getRmStatus().getStatus().equals(
+ PCSHealthMonitorMetKeys.STATUS_UP)) {
+ // print out the batch stubs
+ List<Object> stubs = new Vector<Object>();
+ for (PCSDaemonStatus bStatus : (List<PCSDaemonStatus>) (List<?>) report
+ .getBatchStubStatus()) {
+ stubs.add(this.encodeDaemonStatus(bStatus));
+ }
+ daemonOutput.put("stubs", stubs);
+ } else
+ throw new ResourceNotFoundException(
+ "Resource Manager not running so no batch stubs to check.");
+ } else
+ throw new ResourceNotFoundException("Daemon not found");
+
+ output.put("daemonStatus", daemonOutput);
+ return this.encodeReportAsJson(output);
+
+ }
+
+ @GET
+ @Path("report/crawlers")
+ @Produces("text/plain")
+ public String crawlerHealthReport() {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ Map<String, Object> crawlerOutput = new HashMap<String, Object>();
+ for (CrawlerStatus cs : (List<CrawlerStatus>) (List<?>) report
+ .getCrawlerStatus()) {
+ crawlerOutput.put(cs.getInfo().getCrawlerName(), this
+ .encodeCrawlerStatus(cs));
+ }
+
+ output.put("crawlerStatus", crawlerOutput);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/crawlers/{cname}")
+ @Produces("text/plain")
+ public String getCrawlerHealthReportByName(
+ @PathParam("cname") String crawlerName) {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ Map<String, Object> crawlerOutput = new HashMap<String, Object>();
+ boolean found = false;
+ for (CrawlerStatus cs : (List<CrawlerStatus>) (List<?>) report
+ .getCrawlerStatus()) {
+ if (cs.getInfo().getCrawlerName().equals(crawlerName)) {
+ crawlerOutput.put(cs.getInfo().getCrawlerName(), this
+ .encodeCrawlerStatus(cs));
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ throw new ResourceNotFoundException(
+ "Unable to find any crawlers with name: [" + crawlerName + "]");
+
+ output.put("crawlerStatus", crawlerOutput);
+ return this.encodeReportAsJson(output);
+ }
+
+ @GET
+ @Path("report/latestfiles")
+ @Produces("text/plain")
+ public String getLatestIngestedFiles() {
+ PCSHealthMonitorReport report = mon.getReport();
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("generated", report.getCreateDateIsoFormat());
+ Map<String, Object> latestFilesOutput = new HashMap<String, Object>();
+ latestFilesOutput.put("topN", PCSHealthMonitor.TOP_N_PRODUCTS);
+ List<Object> latestFilesList = new Vector<Object>();
+ for (Product prod : (List<Product>) (List<?>) report
+ .getLatestProductsIngested()) {
+ try {
+ this.encodeLatestFile(latestFilesList, prod);
+ } catch (MalformedURLException e) {
+ LOG.log(Level.WARNING, "Unable to encode latest file: ["
+ + prod.getProductName() + "]: error: Message: " + e.getMessage());
+ }
+ }
+
+ latestFilesOutput.put("files", latestFilesList);
+ output.put("latestFiles", latestFilesOutput);
+ return this.encodeReportAsJson(output);
+ }
+
+ private String encodeReportAsJson(Map<String, Object> reportHash) {
+ JSONObject response = new JSONObject();
+ response.put("report", reportHash);
+ return response.toString();
+ }
+
+ private Map<String, Object> encodeCrawlerHealth(CrawlerHealth health) {
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("crawler", health.getCrawlerName());
+ output.put("avgCrawlTime", health.getAvgCrawlTime());
+ output.put("numCrawls", health.getNumCrawls());
+ return output;
+ }
+
+ private Map<String, Object> encodeJobStatus(JobHealthStatus status) {
+ Map<String, Object> output = new HashMap<String, Object>();
+ output.put("state", status.getStatus());
+ output.put("numJobs", status.getNumPipelines());
+ return output;
+ }
+
+ private void encodeLatestFile(List<Object> latestFilesOutput, Product p)
+ throws MalformedURLException {
+ FileManagerUtils fm = new FileManagerUtils(PCSService.conf.getFmUrl());
+ p.setProductType(fm.safeGetProductTypeById(p.getProductType()
+ .getProductTypeId()));
+ p.setProductReferences(fm.safeGetProductReferences(p));
+ Metadata prodMet = fm.safeGetMetadata(p);
+ if(prodMet == null) prodMet = new Metadata();
+ Map<String, Object> fileOutput = new HashMap<String, Object>();
+ fileOutput.put("filepath", fm.getFilePath(p));
+ fileOutput.put("receivedTime", prodMet.getMetadata("CAS."
+ + CoreMetKeys.PRODUCT_RECEVIED_TIME) != null ?
+ prodMet.getMetadata("CAS."
+ + CoreMetKeys.PRODUCT_RECEVIED_TIME):"UNKNOWN");
+ latestFilesOutput.add(fileOutput);
+ }
+
+ private Map<String, String> encodeCrawlerStatus(CrawlerStatus status) {
+ Map<String, String> output = new HashMap<String, String>();
+ output.put("crawlerName", status.getInfo().getCrawlerName());
+ output.put("crawlerPort", status.getInfo().getCrawlerPort());
+ output.put("url", status.getCrawlHost());
+ output.put("status", status.getStatus());
+ return output;
+ }
+
+ private Map<String, String> encodeDaemonStatus(PCSDaemonStatus status) {
+ Map<String, String> output = new HashMap<String, String>();
+ output.put("daemon", status.getDaemonName());
+ output.put("url", status.getUrlStr());
+ output.put("status", status.getStatus());
+ return output;
+ }
+
+ private class ResourceNotFoundException extends WebApplicationException {
+
+ public ResourceNotFoundException() {
+ super(Response.status(Status.NOT_FOUND).type(MediaType.TEXT_PLAIN)
+ .build());
+ }
+
+ public ResourceNotFoundException(String msg) {
+ super(Response.status(Status.NOT_FOUND).entity(msg).type(
+ MediaType.TEXT_PLAIN).build());
+ }
+ }
+}
Propchange:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/HealthResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSService.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSService.java?rev=1071097&view=auto
==============================================================================
---
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSService.java
(added)
+++
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSService.java
Tue Feb 15 22:53:22 2011
@@ -0,0 +1,50 @@
+/**
+ * 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.oodt.pcs.services;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+
+/**
+ *
+ * Base class for PCS JAX-RS services. Loads up
+ * the {@link PCSServiceConfig} and makes it available
+ * statically to downstream descendants.
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+public class PCSService extends HttpServlet {
+
+ protected static final long serialVersionUID = 6256089700429938496L;
+
+ protected static PCSServiceConfig conf;
+
+
+ /* (non-Javadoc)
+ * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
+ */
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ conf = new PCSServiceConfig(config);
+ }
+
+}
Propchange:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSService.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfMetKeys.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfMetKeys.java?rev=1071097&view=auto
==============================================================================
---
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfMetKeys.java
(added)
+++
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfMetKeys.java
Tue Feb 15 22:53:22 2011
@@ -0,0 +1,44 @@
+/**
+ * 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.oodt.pcs.services;
+
+/**
+ *
+ * Config file met keys for the PCS services <code>context.xml</code> file.
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+public interface PCSServiceConfMetKeys {
+
+ public static final String FM_URL = "org.apache.oodt.cas.fm.url";
+
+ public static final String WM_URL = "org.apache.oodt.cas.wm.url";
+
+ public static final String RM_URL = "org.apache.oodt.cas.rm.url";
+
+ public static final String PCS_LL_CONF_FILE_PATH =
"org.apache.oodt.pcs.ll.conf.filePath";
+
+ public static final String PCS_HEALTH_CRAWLER_CONF_PATH =
"org.apache.oodt.pcs.health.crawler.conf.filePath";
+
+ public static final String PCS_HEALTH_WORKFLOW_STATUS_PATH =
"org.apache.oodt.pcs.health.workflow.statuses.filePath";
+
+ public static final String PCS_TRACE_ENABLE_NON_CAT =
"org.apache.oodt.pcs.trace.enableNonCat";
+
+}
Propchange:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfMetKeys.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfig.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfig.java?rev=1071097&view=auto
==============================================================================
---
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfig.java
(added)
+++
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfig.java
Tue Feb 15 22:53:22 2011
@@ -0,0 +1,120 @@
+/**
+ * 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.oodt.pcs.services;
+
+//JDK imports
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.ServletConfig;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.util.PathUtils;
+
+/**
+ *
+ * The configuration class for the PCS JAX RS services.
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+public class PCSServiceConfig implements PCSServiceConfMetKeys {
+
+ private Map<String, String> parameters;
+
+ private static final Logger LOG = Logger.getLogger(PCSServiceConfig.class
+ .getName());
+
+ public PCSServiceConfig(ServletConfig config) {
+ this.parameters = new HashMap<String, String>();
+ this.readContextParams(config);
+ }
+
+ /**
+ * @return the fmUrl
+ * @throws MalformedURLException
+ */
+ public URL getFmUrl() throws MalformedURLException {
+ return new URL(PathUtils.replaceEnvVariables(this.parameters.get(FM_URL)));
+ }
+
+ /**
+ * @return the wmUrl
+ * @throws MalformedURLException
+ */
+ public URL getWmUrl() throws MalformedURLException {
+ return new URL(PathUtils.replaceEnvVariables(this.parameters.get(WM_URL)));
+ }
+
+ /**
+ * @return the rmUrl
+ * @throws MalformedURLException
+ */
+ public URL getRmUrl() throws MalformedURLException {
+ return new URL(PathUtils.replaceEnvVariables(this.parameters.get(RM_URL)));
+ }
+
+ /**
+ * @return the listingConfFilePath
+ */
+ public String getListingConfFilePath() {
+ return PathUtils.replaceEnvVariables(this.parameters
+ .get(PCS_LL_CONF_FILE_PATH));
+ }
+
+ /**
+ * @return the crawlerConfigFilePath
+ */
+ public String getCrawlerConfigFilePath() {
+ return PathUtils.replaceEnvVariables(this.parameters
+ .get(PCS_HEALTH_CRAWLER_CONF_PATH));
+ }
+
+ /**
+ * @return the workflowStatusesFilePath
+ */
+ public String getWorkflowStatusesFilePath() {
+ return PathUtils.replaceEnvVariables(this.parameters
+ .get(PCS_HEALTH_WORKFLOW_STATUS_PATH));
+ }
+
+ /**
+ * @return the traceNotCatalogedFiles
+ */
+ public boolean isTraceNotCatalogedFiles() {
+ return Boolean.valueOf(this.parameters.get(PCS_TRACE_ENABLE_NON_CAT));
+ }
+
+ @SuppressWarnings("unchecked")
+ private void readContextParams(ServletConfig config) {
+ for (Enumeration<String> paramNames = config.getServletContext()
+ .getInitParameterNames(); paramNames.hasMoreElements();) {
+ String paramName = paramNames.nextElement();
+ this.parameters.put(paramName, config.getServletContext()
+ .getInitParameter(paramName));
+ }
+
+ LOG.log(Level.INFO, "Init Parameters: " + this.parameters);
+ }
+
+}
Propchange:
oodt/trunk/pcs/services/src/main/java/org/apache/oodt/pcs/services/PCSServiceConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: oodt/trunk/pcs/services/src/main/webapp/META-INF/context.xml
URL:
http://svn.apache.org/viewvc/oodt/trunk/pcs/services/src/main/webapp/META-INF/context.xml?rev=1071097&view=auto
==============================================================================
--- oodt/trunk/pcs/services/src/main/webapp/META-INF/context.xml (added)
+++ oodt/trunk/pcs/services/src/main/webapp/META-INF/context.xml Tue Feb 15
22:53:22 2011
@@ -0,0 +1,41 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more contributor
+license agreements. See the NOTICE.txt 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.
+-->
+<Context path="/pcs" docBase="/path/to/pcs-services-X.Y.war">
+
+ <Parameter name="org.apache.oodt.cas.fm.url"
+ value="http://localhost:9000"/>
+
+ <Parameter name="org.apache.oodt.cas.wm.url"
+ value="http://localhost:9001"/>
+
+ <Parameter name="org.apache.oodt.cas.rm.url"
+ value="http://localhost:9002"/>
+
+ <Parameter name="org.apache.oodt.pcs.ll.conf.filePath"
+ value="/path/to/pcs-ll-conf.xmnl"/>
+
+ <Parameter name="org.apache.oodt.pcs.health.crawler.conf.filePath"
+
value="/Users/mattmann/src/oodt/trunk/pcs/core/src/main/resources/pcs-crawlers.xml"/>
+
+ <Parameter name="org.apache.oodt.pcs.health.workflow.statuses.filePath"
+
value="/Users/mattmann/src/oodt/trunk/pcs/core/src/main/resources/pcs-workflow-statuses.xml"/>
+
+ <Parameter name="org.apache.oodt.pcs.trace.enableNonCat"
+ value="true"/>
+
+</Context>
Added: oodt/trunk/pcs/services/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/oodt/trunk/pcs/services/src/main/webapp/WEB-INF/web.xml?rev=1071097&view=auto
==============================================================================
--- oodt/trunk/pcs/services/src/main/webapp/WEB-INF/web.xml (added)
+++ oodt/trunk/pcs/services/src/main/webapp/WEB-INF/web.xml Tue Feb 15 22:53:22
2011
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more contributor
+license agreements. See the NOTICE.txt 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.
+-->
+<web-app id="PCS" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>PCS</display-name>
+ <servlet>
+ <servlet-name>CXFServlet</servlet-name>
+ <servlet-class>
+ org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
+ </servlet-class>
+ <init-param>
+ <param-name>jaxrs.serviceClasses</param-name>
+ <param-value>
+ org.apache.oodt.pcs.services.HealthResource
+ </param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet>
+ <display-name>PCS Service</display-name>
+ <servlet-name>PCS Service</servlet-name>
+ <servlet-class>org.apache.oodt.pcs.services.PCSService</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>CXFServlet</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+</web-app>