This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BZ-1206627, BZ-1198662: improvements on shutdown (now with priority f…
…eture of shutdown services) and additional improvements on git and cluster lock mechanism
- Loading branch information
Showing
29 changed files
with
410 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...ackend-server/src/main/java/org/uberfire/backend/server/io/DisposableShutdownService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.uberfire.backend.server.io; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Comparator; | ||
import javax.annotation.PostConstruct; | ||
import javax.enterprise.inject.Instance; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.servlet.ServletContextEvent; | ||
import javax.servlet.ServletContextListener; | ||
|
||
import org.uberfire.commons.async.SimpleAsyncExecutorService; | ||
import org.uberfire.commons.cluster.ClusterService; | ||
import org.uberfire.commons.cluster.ClusterServiceFactory; | ||
import org.uberfire.commons.lifecycle.Disposable; | ||
import org.uberfire.commons.lifecycle.PriorityDisposable; | ||
import org.uberfire.java.nio.file.api.FileSystemProviders; | ||
import org.uberfire.java.nio.file.spi.FileSystemProvider; | ||
|
||
public class DisposableShutdownService implements ServletContextListener { | ||
|
||
@Inject | ||
private Instance<PriorityDisposable> disposables; | ||
|
||
@Inject | ||
@Named("clusterServiceFactory") | ||
private ClusterServiceFactory clusterServiceFactory; | ||
|
||
private ClusterService clusterService = null; | ||
|
||
@PostConstruct | ||
public void init() { | ||
if ( clusterServiceFactory != null ) { | ||
//TODO: hack that should be changed soon; | ||
clusterService = clusterServiceFactory.build( null ); | ||
} | ||
} | ||
|
||
@Override | ||
public void contextInitialized( ServletContextEvent sce ) { | ||
|
||
} | ||
|
||
@Override | ||
public void contextDestroyed( final ServletContextEvent sce ) { | ||
final ArrayList<PriorityDisposable> collection = new ArrayList<PriorityDisposable>(); | ||
for ( final PriorityDisposable disposable : disposables ) { | ||
collection.add( disposable ); | ||
} | ||
|
||
Collections.sort( collection, new Comparator<PriorityDisposable>() { | ||
@Override | ||
public int compare( final PriorityDisposable o1, | ||
final PriorityDisposable o2 ) { | ||
return ( o2.priority() < o1.priority() ) ? -1 : ( ( o2.priority() == o1.priority() ) ? 0 : 1 ); | ||
} | ||
} ); | ||
|
||
if ( clusterService != null ) { | ||
clusterService.lock(); | ||
} | ||
|
||
for ( final PriorityDisposable disposable : collection ) { | ||
disposable.dispose(); | ||
} | ||
|
||
SimpleAsyncExecutorService.shutdownInstances(); | ||
|
||
for ( final FileSystemProvider fileSystemProvider : FileSystemProviders.installedProviders() ) { | ||
if ( fileSystemProvider instanceof Disposable ) { | ||
( (Disposable) fileSystemProvider ).dispose(); | ||
} | ||
} | ||
|
||
if ( clusterService != null ) { | ||
clusterService.unlock(); | ||
clusterService.dispose(); | ||
} | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
...backend-server/src/main/java/org/uberfire/backend/server/io/IOServiceShutdownService.java
This file was deleted.
Oops, something went wrong.
10 changes: 4 additions & 6 deletions
10
uberfire-commons/src/main/java/org/uberfire/commons/cluster/ClusterService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
package org.uberfire.commons.cluster; | ||
|
||
import org.uberfire.commons.lifecycle.PriorityDisposable; | ||
import org.uberfire.commons.lock.LockService; | ||
import org.uberfire.commons.message.MessageHandlerResolver; | ||
import org.uberfire.commons.message.MessageService; | ||
|
||
public interface ClusterService extends MessageService, | ||
LockService { | ||
LockService, | ||
PriorityDisposable { | ||
|
||
void addMessageHandlerResolver( final MessageHandlerResolver resolver ); | ||
|
||
void start(); | ||
|
||
void dispose(); | ||
|
||
void onStart( Runnable runnable ); | ||
|
||
boolean isInnerLocked(); | ||
int getHoldCount(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,6 @@ | |
|
||
public interface Disposable { | ||
|
||
public void dispose(); | ||
void dispose(); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
uberfire-commons/src/main/java/org/uberfire/commons/lifecycle/PriorityDisposable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2014 JBoss, by Red Hat, Inc | ||
* | ||
* Licensed 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.uberfire.commons.lifecycle; | ||
|
||
public interface PriorityDisposable extends Disposable { | ||
|
||
int priority(); | ||
|
||
} |
4 changes: 1 addition & 3 deletions
4
uberfire-commons/src/main/java/org/uberfire/commons/lock/LockService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
package org.uberfire.commons.lock; | ||
|
||
public abstract interface LockService { | ||
public interface LockService { | ||
|
||
void lock(); | ||
|
||
void unlock(); | ||
|
||
boolean isLocked(); | ||
} |
52 changes: 0 additions & 52 deletions
52
uberfire-commons/src/main/java/org/uberfire/commons/lock/impl/ThreadLockServiceImpl.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
uberfire-io/src/main/java/org/uberfire/io/IOClusteredService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.