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:
parent
a4786060f4
commit
b801e9f155
1
pom.xml
1
pom.xml
|
@ -109,6 +109,7 @@
|
||||||
<directory>${distroDirectory}</directory>
|
<directory>${distroDirectory}</directory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>gcube-app.xml</include>
|
<include>gcube-app.xml</include>
|
||||||
|
<include>gcube-handlers.xml</include>
|
||||||
</includes>
|
</includes>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
|
@ -92,12 +92,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
|
||||||
* @throws RegistryNotFoundException if the Registry is not found so the
|
* @throws RegistryNotFoundException if the Registry is not found so the
|
||||||
* resource has not be published
|
* 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();
|
StringWriter stringWriter = new StringWriter();
|
||||||
Resources.marshal(resource, stringWriter);
|
Resources.marshal(resource, stringWriter);
|
||||||
|
|
||||||
List<String> scopes = ctx.configuration().startScopes();
|
|
||||||
|
|
||||||
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
|
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
|
||||||
try {
|
try {
|
||||||
logger.debug(String.format("Trying to publish %s", stringWriter.toString()));
|
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
|
* @throws RegistryNotFoundException if the Registry is not found so the
|
||||||
* resource has not be published
|
* 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();
|
StringWriter stringWriter = new StringWriter();
|
||||||
Resources.marshal(resource, stringWriter);
|
Resources.marshal(resource, stringWriter);
|
||||||
|
|
||||||
List<String> scopes = ctx.configuration().startScopes();
|
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
|
||||||
|
|
||||||
ScopedPublisher scopedPublisher = RegistryPublisherFactory.scopedPublisher();
|
|
||||||
try {
|
try {
|
||||||
logger.debug(String.format("Trying to publish %s", stringWriter.toString()));
|
logger.debug(String.format("Trying to publish %s", stringWriter.toString()));
|
||||||
scopedPublisher.remove(resource, scopes);
|
scopedPublisher.remove(resource, scopes);
|
||||||
|
@ -178,6 +174,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onStart(ContainerLifecycleEvent.Start containerLifecycleEventStart) {
|
public void onStart(ContainerLifecycleEvent.Start containerLifecycleEventStart) {
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
|
logger.debug("Smart Executor is Starting");
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
|
|
||||||
pool = Executors.newCachedThreadPool();
|
pool = Executors.newCachedThreadPool();
|
||||||
|
|
||||||
serviceEndpoint = ExecutorImpl.createServiceEndpoint();
|
serviceEndpoint = ExecutorImpl.createServiceEndpoint();
|
||||||
|
@ -193,7 +193,7 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
|
||||||
// room
|
// room
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ExecutorImpl.publishScopedResource(serviceEndpoint, ctx);
|
ExecutorImpl.publishScopedResource(serviceEndpoint, ctx.configuration().startScopes());
|
||||||
} catch (RegistryNotFoundException e) {
|
} catch (RegistryNotFoundException e) {
|
||||||
logger.error("Unable to Create ServiceEndpoint. the Service will be aborted", e);
|
logger.error("Unable to Create ServiceEndpoint. the Service will be aborted", e);
|
||||||
return;
|
return;
|
||||||
|
@ -208,6 +208,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
|
||||||
logger.error("Unable to initialize PersistenceConnector. The Service will be aborted", e);
|
logger.error("Unable to initialize PersistenceConnector. The Service will be aborted", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
|
logger.debug("Smart Executor Started Successfully");
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@ -218,6 +222,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onStop(ContainerLifecycleEvent.Stop containerLifecycleEventStop) {
|
public void onStop(ContainerLifecycleEvent.Stop containerLifecycleEventStop) {
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
|
logger.debug("Smart Executor is Stoppin");
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
|
|
||||||
|
|
||||||
for(UUID uuid : pluginInstances.keySet()){
|
for(UUID uuid : pluginInstances.keySet()){
|
||||||
PluginThread<Plugin<? extends PluginDeclaration>> pluginThread =
|
PluginThread<Plugin<? extends PluginDeclaration>> pluginThread =
|
||||||
|
@ -247,7 +255,7 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
|
||||||
pool.shutdown();
|
pool.shutdown();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ExecutorImpl.unPublishScopedResource(serviceEndpoint, ctx);
|
ExecutorImpl.unPublishScopedResource(serviceEndpoint, ctx.configuration().startScopes());
|
||||||
} catch (RegistryNotFoundException e) {
|
} catch (RegistryNotFoundException e) {
|
||||||
logger.error("Unable to unpublish Service Endpoint.", e);
|
logger.error("Unable to unpublish Service Endpoint.", e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -259,6 +267,10 @@ public class ExecutorImpl extends ContainerHandler implements Executor {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to close Persistence", e);
|
logger.error("Unable to close Persistence", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
|
logger.debug("Smart Executor Stopped Successfully");
|
||||||
|
logger.debug("-------------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue