Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Activator implements BundleActivator {

public void start(BundleContext bundleContext) throws Exception {
QuiesceManager manager = new QuiesceManagerImpl(bundleContext);
serviceReg = bundleContext.registerService(QuiesceManager.class.getName(), manager, null);
serviceReg = bundleContext.registerService(QuiesceManager.class, manager, null);
}

public void stop(BundleContext bundleContext) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.apache.aries.quiesce.manager.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -97,7 +98,7 @@

public Future<?> quiesceWithFuture(long timeout, List<Bundle> bundles) {
QuiesceFuture result = new QuiesceFuture();
if (bundles != null && !!!bundles.isEmpty()) {
if (bundles != null && !bundles.isEmpty()) {
//check that bundle b is not already quiescing
Iterator<Bundle> it = bundles.iterator();
Set<Bundle> bundlesToQuiesce = new HashSet<Bundle>();
Expand Down Expand Up @@ -134,7 +135,7 @@
}

public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
if (!!!latch.await(timeout, unit))
if (!latch.await(timeout, unit))
throw new TimeoutException();

return null;
Expand All @@ -149,7 +150,7 @@
}

public void registerDone() {
if (!!!isDone()) {
if (!isDone()) {
latch.countDown();
}
}
Expand Down Expand Up @@ -217,8 +218,9 @@
public void run() {
try {
if (bundleContext != null) {
ServiceReference[] serviceRefs = bundleContext.getServiceReferences(QuiesceParticipant.class.getName(), null);
if (serviceRefs != null) {
Collection<ServiceReference<QuiesceParticipant>> serviceRefs =
bundleContext.getServiceReferences(QuiesceParticipant.class, null);
if (serviceRefs != null && !serviceRefs.isEmpty()) {
List<QuiesceParticipant> participants = new ArrayList<QuiesceParticipant>();
final List<QuiesceCallbackImpl> callbacks = new ArrayList<QuiesceCallbackImpl>();
List<Bundle> copyOfBundles = new ArrayList<Bundle>(bundlesToQuiesce);
Expand All @@ -241,8 +243,8 @@


//Create callback objects for all participants
for( ServiceReference sr : serviceRefs ) {
QuiesceParticipant participant = (QuiesceParticipant) bundleContext.getService(sr);
for( ServiceReference<QuiesceParticipant> sr : serviceRefs ) {
QuiesceParticipant participant = bundleContext.getService(sr);
participants.add(participant);
callbacks.add(new QuiesceCallbackImpl(bundlesToQuiesce, callbacks, future, timeoutFuture));
}
Expand Down Expand Up @@ -311,16 +313,16 @@

synchronized (allCallbacks) {
for(Bundle b : bundlesQuiesced) {
if(QuiesceManagerImpl.stillQuiescing(b)) {
if(stillQuiescing(b)) {
if(toQuiesce.remove(b)) {
if(checkOthers(b)){
QuiesceManagerImpl.stopBundle(b, toQuiesceShared);
stopBundle(b, toQuiesceShared);
if(allCallbacksComplete()){
future.registerDone();
timeoutFuture.cancel(false);
LOGGER.debug("Quiesce complete");
}
}

Check warning on line 325 in quiesce/quiesce-manager/src/main/java/org/apache/aries/quiesce/manager/impl/QuiesceManagerImpl.java

View workflow job for this annotation

GitHub Actions / PMD

Design CollapsibleIfStatements

This if statement could be combined with its parent
}
} else {
timeoutOccurred = true;
Expand All @@ -340,7 +342,7 @@
boolean allDone = true;
Iterator<QuiesceCallbackImpl> it = allCallbacks.iterator();
while (allDone && it.hasNext()) {
allDone = !!!it.next().toQuiesce.contains(b);
allDone = !it.next().toQuiesce.contains(b);
}
return allDone;
}
Expand All @@ -350,9 +352,9 @@
Iterator<QuiesceCallbackImpl> it = allCallbacks.iterator();
while (allDone && it.hasNext()) {
QuiesceCallbackImpl next = it.next();
if (!!!next.toQuiesce.isEmpty()) allDone = false;
if (!next.toQuiesce.isEmpty()) allDone = false;
}
return allDone;
}
}
}
}
Loading