Fixing service

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@111755 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-02-06 09:04:58 +00:00
parent a4786060f4
commit b801e9f155
3 changed files with 33 additions and 9 deletions

View File

@ -109,6 +109,7 @@
<directory>${distroDirectory}</directory>
<includes>
<include>gcube-app.xml</include>
<include>gcube-handlers.xml</include>
</includes>
<filtering>true</filtering>
</resource>

View File

@ -92,12 +92,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
* @throws RegistryNotFoundException if the Registry is not found so the
* resource has not be published
*/
private static void publishScopedResource(Resource resource, ContainerContext ctx) throws RegistryNotFoundException, Exception {
private static void publishScopedResource(Resource resource, List<String> scopes) throws RegistryNotFoundException, Exception {
StringWriter stringWriter = new StringWriter();
Resources.marshal(resource, stringWriter);
List<String> scopes = ctx.configuration().startScopes();
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
try {
logger.debug(String.format("Trying to publish %s", stringWriter.toString()));
@ -114,13 +112,11 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
* @throws RegistryNotFoundException if the Registry is not found so the
* resource has not be published
*/
private static void unPublishScopedResource(Resource resource, ContainerContext ctx) throws RegistryNotFoundException, Exception {
private static void unPublishScopedResource(Resource resource, List<String> scopes) throws RegistryNotFoundException, Exception {
StringWriter stringWriter = new StringWriter();
Resources.marshal(resource, stringWriter);
List<String> scopes = ctx.configuration().startScopes();
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
try {
logger.debug(String.format("Trying to publish %s", stringWriter.toString()));
scopedPublisher.remove(resource, scopes);
@ -178,6 +174,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
*/
@Override
public void onStart(ContainerLifecycleEvent.Start containerLifecycleEventStart) {
logger.debug("-------------------------------------------------------");
logger.debug("Smart Executor is Starting");
logger.debug("-------------------------------------------------------");
pool = Executors.newCachedThreadPool();
serviceEndpoint = ExecutorImpl.createServiceEndpoint();
@ -193,7 +193,7 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
// room
try {
ExecutorImpl.publishScopedResource(serviceEndpoint, ctx);
ExecutorImpl.publishScopedResource(serviceEndpoint, ctx.configuration().startScopes());
} catch (RegistryNotFoundException e) {
logger.error("Unable to Create ServiceEndpoint. the Service will be aborted", e);
return;
@ -208,6 +208,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
logger.error("Unable to initialize PersistenceConnector. The Service will be aborted", e);
return;
}
logger.debug("-------------------------------------------------------");
logger.debug("Smart Executor Started Successfully");
logger.debug("-------------------------------------------------------");
}
/** {@inheritDoc} */
@ -218,6 +222,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
*/
@Override
public void onStop(ContainerLifecycleEvent.Stop containerLifecycleEventStop) {
logger.debug("-------------------------------------------------------");
logger.debug("Smart Executor is Stoppin");
logger.debug("-------------------------------------------------------");
for(UUID uuid : pluginInstances.keySet()){
PluginThread<Plugin<? extends PluginDeclaration>> pluginThread =
@ -247,7 +255,7 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
pool.shutdown();
try {
ExecutorImpl.unPublishScopedResource(serviceEndpoint, ctx);
ExecutorImpl.unPublishScopedResource(serviceEndpoint, ctx.configuration().startScopes());
} catch (RegistryNotFoundException e) {
logger.error("Unable to unpublish Service Endpoint.", e);
} catch (Exception e) {
@ -259,6 +267,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
} catch (Exception e) {
logger.error("Unable to close Persistence", e);
}
logger.debug("-------------------------------------------------------");
logger.debug("Smart Executor Stopped Successfully");
logger.debug("-------------------------------------------------------");
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<handlers>
<lifecycle>
<profile-management />
<plugin-registration-handler />
</lifecycle>
<request>
<request-validation />
</request>
</handlers>