You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/03/10 10:43:20 UTC
[09/20] git commit: keep agent live extension
keep agent live extension
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/87053224
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/87053224
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/87053224
Branch: refs/heads/master
Commit: 870532240876fb86a9ddebd9e605b77f6e3c7db4
Parents: e29baca
Author: Nirmal Fernando <ni...@apache.org>
Authored: Mon Mar 10 15:02:08 2014 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Mon Mar 10 15:02:08 2014 +0530
----------------------------------------------------------------------
.../impl/KeepAgentLiveExtensionExecutor.java | 68 ++++++++++++++++++++
1 file changed, 68 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/87053224/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/KeepAgentLiveExtensionExecutor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/KeepAgentLiveExtensionExecutor.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/KeepAgentLiveExtensionExecutor.java
new file mode 100644
index 0000000..5cccdb1
--- /dev/null
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/executor/impl/KeepAgentLiveExtensionExecutor.java
@@ -0,0 +1,68 @@
+/*
+ * 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.stratos.cartridge.agent.executor.impl;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cartridge.agent.executor.ExtensionExecutor;
+import org.apache.stratos.cartridge.agent.runtime.DataHolder;
+
+/**
+ * This extension is responsible for keeping the agent alive.
+ *
+ */
+public class KeepAgentLiveExtensionExecutor extends ExtensionExecutor {
+
+ private static final Log log = LogFactory.getLog(KeepAgentLiveExtensionExecutor.class);
+
+ public KeepAgentLiveExtensionExecutor() {
+ super(KeepAgentLiveExtensionExecutor.class.getName());
+ }
+
+ public KeepAgentLiveExtensionExecutor(List<String> fileNames) {
+ super.setFileNamesToBeExecuted(fileNames);
+ }
+
+ @Override
+ public void execute() {
+ try {
+ if(log.isDebugEnabled()) {
+ log.debug("Executing Extension: "+super.getId());
+ }
+ while (!DataHolder.getInstance().isTerminated()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ }
+ }
+ catch (Exception e) {
+ log.error("Could not execute extension: "+super.getId() , e);
+ }
+ }
+
+ @Override
+ public void cleanUp() {
+ }
+
+
+}