Hi Chamila,
Please find the attached diff for the changes in master branch.
On Thu, Mar 26, 2015 at 11:07 AM, Anuruddha Liyanarachchi <
[email protected]> wrote:
> Hi Chamila,
>
> I will resend the diff rebased for master.
>
> On Thu, Mar 26, 2015 at 11:01 AM, Chamila De Alwis <[email protected]>
> wrote:
>
>> Hi Anuruddha,
>>
>> This seems to be based on 4.0.0-rc4 tag. Can you resend it by rebasing
>> for master?
>>
>>
>> Regards,
>> Chamila de Alwis
>> Software Engineer | WSO2 | +94772207163
>> Blog: code.chamiladealwis.com
>>
>>
>>
>> On Tue, Mar 24, 2015 at 2:35 PM, Anuruddha Liyanarachchi <
>> [email protected]> wrote:
>>
>>> Hi Chamila,
>>>
>>> Please find the diff with changes to fix the issue.
>>> WDYT ?
>>>
>>> On Tue, Mar 24, 2015 at 1:50 PM, Chamila De Alwis <[email protected]>
>>> wrote:
>>>
>>>> Hi Anuruddha,
>>>>
>>>> Yes, this seems to be missing from the ArtifactUpdatedEvent processing.
>>>> If the extension is being manually executed in the non-repo based path, it
>>>> should also be the case in the repo based path. It might have been dropped
>>>> while being refactored.
>>>>
>>>>
>>>> Regards,
>>>> Chamila de Alwis
>>>> Software Engineer | WSO2 | +94772207163
>>>> Blog: code.chamiladealwis.com
>>>>
>>>>
>>>>
>>>> On Tue, Mar 24, 2015 at 12:51 PM, Anuruddha Liyanarachchi <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Found that the instance activated extension is not getting called
>>>>> when onArtifactUpdatedEvent is publishing Instance activated event.
>>>>> However
>>>>> artifactUpdate extension is getting called.
>>>>>
>>>>> Shouldn't artifactUpdatedEvent trigger both instanceActivated and
>>>>> artifactUpdated Extensions?
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Thanks and Regards,*
>>>>> Anuruddha Lanka Liyanarachchi
>>>>> Software Engineer - WSO2
>>>>> Mobile : +94 (0) 712762611
>>>>> Tel : +94 112 145 345
>>>>> a <[email protected]>[email protected]
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> *Thanks and Regards,*
>>> Anuruddha Lanka Liyanarachchi
>>> Software Engineer - WSO2
>>> Mobile : +94 (0) 712762611
>>> Tel : +94 112 145 345
>>> a <[email protected]>[email protected]
>>>
>>
>>
>
>
> --
> *Thanks and Regards,*
> Anuruddha Lanka Liyanarachchi
> Software Engineer - WSO2
> Mobile : +94 (0) 712762611
> Tel : +94 112 145 345
> a <[email protected]>[email protected]
>
--
*Thanks and Regards,*
Anuruddha Lanka Liyanarachchi
Software Engineer - WSO2
Mobile : +94 (0) 712762611
Tel : +94 112 145 345
a <[email protected]>[email protected]
diff --git
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
index 41abfc2..993c17d 100644
---
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
+++
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java
@@ -120,10 +120,6 @@ public class CartridgeAgent implements Runnable {
}
}
- // Wait for all ports to be active
-
CartridgeAgentUtils.waitUntilPortsActive(CartridgeAgentConfiguration.getInstance().getListenAddress(),
- CartridgeAgentConfiguration.getInstance().getPorts());
-
// Check repo url
String repoUrl =
CartridgeAgentConfiguration.getInstance().getRepoUrl();
/*if(CartridgeAgentConfiguration.getInstance().isMultitenant()) {
@@ -150,11 +146,13 @@ public class CartridgeAgent implements Runnable {
if (log.isInfoEnabled()) {
log.info("No artifact repository found");
}
- // Execute instance activated shell script
- extensionHandler.onInstanceActivatedEvent();
// Publish instance activated event
CartridgeAgentEventPublisher.publishInstanceActivatedEvent();
+
+ // Execute instance activated shell script
+ extensionHandler.onInstanceActivatedEvent();
+
} else {
//Start periodical file checker task
/*if
(CartridgeAgentConfiguration.getInstance().isCommitsEnabled()) {
diff --git
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
index ee89c79..ab28592 100644
---
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
+++
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.cartridge.agent.config.CartridgeAgentConfiguration;
import
org.apache.stratos.cartridge.agent.statistics.publisher.HealthStatisticsNotifier;
+import org.apache.stratos.cartridge.agent.util.CartridgeAgentUtils;
import org.apache.stratos.messaging.broker.publish.EventPublisher;
import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
import
org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
@@ -34,6 +35,8 @@ import
org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdow
import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
import org.apache.stratos.messaging.util.Constants;
+import java.util.List;
+
/**
* Cartridge agent event publisher.
*/
@@ -69,7 +72,12 @@ public class CartridgeAgentEventPublisher {
}
public static void publishInstanceStartedEvent() {
- if (!isStarted()) {
+ // Wait for all ports to be active, if ports are not activated, do not
publish instance activated since
+ // the service is not up
+ List<Integer> ports =
CartridgeAgentConfiguration.getInstance().getPorts();
+ String listenAddress =
CartridgeAgentConfiguration.getInstance().getListenAddress();
+ boolean portsActivated =
CartridgeAgentUtils.waitUntilPortsActive(listenAddress, ports);
+ if (!isActivated() && portsActivated) {
if (log.isInfoEnabled()) {
log.info("Publishing instance started event");
}
@@ -88,8 +96,23 @@ public class CartridgeAgentEventPublisher {
}
} else {
- if (log.isWarnEnabled()) {
- log.warn("Instance already started");
+ if (isActivated()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Instance already activated");
+ }
+ }else {
+ //ports are not active
+ if (log.isInfoEnabled()) {
+ // There would not be a large number of ports
+ String portsStr = "";
+ for (Integer port : ports) {
+ portsStr += port + ", ";
+ }
+ log.info(String.format(
+ "Ports activation timed out. Aborting
InstanceActivatedEvent publishing. [IPAddress] %s [Ports] %s",
+ listenAddress,
+ portsStr));
+ }
}
}
}
diff --git
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
index 71f1d96..c416477 100644
---
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
+++
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/extensions/DefaultExtensionHandler.java
@@ -142,6 +142,9 @@ public class DefaultExtensionHandler implements
ExtensionHandler {
if (!cloneExists && !isMultitenant) {
// Executed git clone, publish instance activated event
CartridgeAgentEventPublisher.publishInstanceActivatedEvent();
+
+ // Execute instance activated shell script
+ ExtensionUtils.executeInstanceActivatedExtension();
}
// Start the artifact update task
diff --git
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
index 010462d..5b1d1e9 100644
---
a/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
+++
b/source/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/util/CartridgeAgentUtils.java
@@ -80,7 +80,7 @@ public class CartridgeAgentUtils {
return decryptPassword;
}
- public static void waitUntilPortsActive(String ipAddress, List<Integer>
ports) {
+ public static boolean waitUntilPortsActive(String ipAddress, List<Integer>
ports) {
long portCheckTimeOut = 1000 * 60 * 10;
String portCheckTimeOutStr = System.getProperty("port.check.timeout");
if (StringUtils.isNotBlank(portCheckTimeOutStr)) {
@@ -100,7 +100,7 @@ public class CartridgeAgentUtils {
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
if (duration > portCheckTimeOut) {
- return;
+ return false;
}
try {
Thread.sleep(5000);
@@ -110,6 +110,7 @@ public class CartridgeAgentUtils {
if(log.isInfoEnabled()) {
log.info("Ports activated: [ip] " + ipAddress + " [ports] "+ports);
}
+ return true;
}
public static boolean checkPortsActive(String ipAddress, List<Integer>
ports) {