Skip to content

Commit

Permalink
ISPN-8869 Infinispan subsystem code cleanup.
Browse files Browse the repository at this point in the history
Deprecated method calls replaced and redundant code removed
  • Loading branch information
ryanemerson authored and tristantarrant committed Feb 28, 2018
1 parent 3ae524a commit ffb861d
Show file tree
Hide file tree
Showing 70 changed files with 184 additions and 358 deletions.
Expand Up @@ -79,86 +79,65 @@ private static <T> T doPrivileged(PrivilegedExceptionAction<T> action) throws Pr
}

public static void registerAndStartContainer(final EmbeddedCacheManager container, final Object listener) {
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
@Override
public Void run() {
container.addListener(listener);
container.start();
return null;
}
PrivilegedAction<Void> action = () -> {
container.addListener(listener);
container.start();
return null;
};
doPrivileged(action);
}

public static boolean stopAndUnregisterContainer(final EmbeddedCacheManager container, final Object listener) {
PrivilegedAction<Boolean> action = new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
if (container.getStatus().allowInvocations()) {
container.stop();
container.removeListener(listener);
return true;
} else {
return false;
}
PrivilegedAction<Boolean> action = () -> {
if (container.getStatus().allowInvocations()) {
container.stop();
container.removeListener(listener);
return true;
} else {
return false;
}
};
return doPrivileged(action);
}

public static void defineContainerConfiguration(final EmbeddedCacheManager container, final String name,
final Configuration config) {
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
@Override
public Void run() {
container.defineConfiguration(name, config);
return null;
}
PrivilegedAction<Void> action = () -> {
container.defineConfiguration(name, config);
return null;
};
doPrivileged(action);
}

public static void undefineContainerConfiguration(final EmbeddedCacheManager container, final String name) {
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
@Override
public Void run() {
container.undefineConfiguration(name);
return null;
}
PrivilegedAction<Void> action = () -> {
container.undefineConfiguration(name);
return null;
};
doPrivileged(action);
}

public static <K, V> Cache<K, V> startCache(final EmbeddedCacheManager container, final String name, final String configurationName) {
PrivilegedAction<Cache<K, V>> action = new PrivilegedAction<Cache<K, V>>() {
@Override
public Cache<K, V> run() {
Cache<K, V> cache = container.getCache(name, configurationName);
cache.start();
return cache;
}
PrivilegedAction<Cache<K, V>> action = () -> {
Cache<K, V> cache = container.getCache(name, configurationName);
cache.start();
return cache;
};
return doPrivileged(action);
}

public static void stopCache(final Cache<?, ?> cache) {
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
@Override
public Void run() {
cache.stop();
return null;
}
PrivilegedAction<Void> action = () -> {
cache.stop();
return null;
};
doPrivileged(action);
}

public static void shutdownCache(final Cache<?, ?> cache) {
PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
@Override
public Void run() {
cache.shutdown();
return null;
}
PrivilegedAction<Void> action = () -> {
cache.shutdown();
return null;
};
doPrivileged(action);
}
Expand Down Expand Up @@ -286,12 +265,7 @@ public static <T extends JmxStatisticsExposer> Void resetStatistics(AdvancedCach

public static Map<String, String> executeInterpreter(final Interpreter interpreter, final String sessionId,
final String command) throws Exception {
PrivilegedExceptionAction<Map<String, String>> action = new PrivilegedExceptionAction<Map<String, String>>() {
@Override
public Map<String, String> run() throws Exception {
return interpreter.execute(sessionId, command);
}
};
PrivilegedExceptionAction<Map<String, String>> action = () -> interpreter.execute(sessionId, command);
return doPrivileged(action);
}

Expand Down
Expand Up @@ -14,7 +14,7 @@ public class LocalServerTaskRunner implements ServerTaskRunner {

@Override
public <T> CompletableFuture<T> execute(String taskName, TaskContext context) {
ServerTaskWrapper<T> task = getRegistry(context).<T>getTask(taskName);
ServerTaskWrapper<T> task = getRegistry(context).getTask(taskName);
try {
task.inject(context);
return CompletableFuture.completedFuture(task.run());
Expand Down
Expand Up @@ -42,7 +42,7 @@ public List<Task> getTasks() {

@Override
public <T> CompletableFuture<T> runTask(String taskName, TaskContext context, Executor executor) {
ServerTaskWrapper<T> task = registry.<T>getTask(taskName);
ServerTaskWrapper<T> task = registry.getTask(taskName);
if (task == null) {
throw new IllegalArgumentException("Task not found: " + taskName);
}
Expand Down
Expand Up @@ -9,7 +9,6 @@
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.ServicesAttachment;
import org.jboss.modules.Module;
Expand All @@ -32,7 +31,7 @@ public class ServerTaskProcessor implements DeploymentUnitProcessor {
public static final String EXTERNAL_TASK = "ExternalTask";

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
public void deploy(DeploymentPhaseContext phaseContext) {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES);
Expand Down
Expand Up @@ -6,7 +6,6 @@
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;

/**
Expand All @@ -26,7 +25,7 @@ public ServerTaskRegistry getValue() throws IllegalStateException, IllegalArgume
}

@Override
public void start(StartContext context) throws StartException {
public void start(StartContext context) {
InfinispanLogger.ROOT_LOGGER.debugf("Starting DeployedTaskRegistryService");
}

Expand Down
Expand Up @@ -91,8 +91,8 @@ public <K, V> Cache<K, V> getCache(String cacheName) {
*/
@Override
public <K, V> Cache<K, V> getCache(String cacheName, boolean start) {
Cache<K, V> cache = this.cm.<K, V>getCache(this.getCacheName(cacheName), start);
return (cache != null) ? new DelegatingCache<K, V>(cache) : null;
Cache<K, V> cache = this.cm.getCache(this.getCacheName(cacheName), start);
return (cache != null) ? new DelegatingCache<>(cache) : null;
}

/**
Expand All @@ -101,7 +101,7 @@ public <K, V> Cache<K, V> getCache(String cacheName, boolean start) {
*/
@Override
public Set<String> getCacheNames() {
Set<String> names = new HashSet<String>(this.cm.getCacheNames());
Set<String> names = new HashSet<>(this.cm.getCacheNames());
names.add(this.defaultCache);
return names;
}
Expand Down Expand Up @@ -144,7 +144,7 @@ public void removeCache(String cacheName) {

@Override
public EmbeddedCacheManager startCaches(String... names) {
Set<String> cacheNames = new LinkedHashSet<String>();
Set<String> cacheNames = new LinkedHashSet<>();
for (String name: names) {
cacheNames.add(this.getCacheName(name));
}
Expand Down Expand Up @@ -195,7 +195,7 @@ class DelegatingCache<K, V> extends AbstractDelegatingAdvancedCache<K, V> {
super(cache, new AdvancedCacheWrapper<K, V>() {
@Override
public AdvancedCache<K, V> wrap(AdvancedCache<K, V> cache) {
return new DelegatingCache<K, V>(cache);
return new DelegatingCache<>(cache);
}
}
);
Expand Down
Expand Up @@ -42,7 +42,7 @@ public TransactionManagerProvider(TransactionManager tm) {
* @see org.infinispan.transaction.lookup.TransactionManagerLookup#getTransactionManager()
*/
@Override
public TransactionManager getTransactionManager() throws Exception {
public TransactionManager getTransactionManager() {
return this.tm;
}
}
Expand Up @@ -40,7 +40,7 @@ public TransactionSynchronizationRegistryProvider(TransactionSynchronizationRegi
}

@Override
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() throws Exception {
public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
return tsr;
}
}
Expand Up @@ -22,7 +22,6 @@

package org.jboss.as.clustering.infinispan.affinity;

import java.security.AccessController;
import java.util.Collections;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand All @@ -36,7 +35,6 @@
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;
import org.jboss.threads.JBossThreadFactory;

Expand Down Expand Up @@ -66,10 +64,10 @@ public KeyAffinityServiceFactory getValue() {
}

@Override
public void start(StartContext context) throws StartException {
public void start(StartContext context) {
final ThreadGroup threadGroup = new ThreadGroup("KeyAffinityService ThreadGroup");
final String namePattern = "KeyAffinityService Thread Pool -- %t";
final ThreadFactory threadFactory = new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null, AccessController.getContext());
final ThreadFactory threadFactory = new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null);

this.executor = Executors.newCachedThreadPool(threadFactory);
}
Expand All @@ -82,7 +80,7 @@ public void stop(StopContext context) {
@Override
public <K> KeyAffinityService<K> createService(Cache<K, ?> cache, KeyGenerator<K> generator) {
boolean distributed = cache.getCacheConfiguration().clustering().cacheMode().isDistributed();
return distributed ? new KeyAffinityServiceImpl<K>(this.executor, cache, generator, this.bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<K>(generator);
return distributed ? new KeyAffinityServiceImpl<>(this.executor, cache, generator, this.bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<>(generator);
}

private static class SimpleKeyAffinityService<K> implements KeyAffinityService<K> {
Expand Down
Expand Up @@ -43,7 +43,7 @@ public AtomicMapCache(AdvancedCache<K, Map<MK, MV>> cache) {
super(cache, new AdvancedCacheWrapper<K, Map<MK, MV>>() {
@Override
public AdvancedCache<K, Map<MK, MV>> wrap(AdvancedCache<K, Map<MK, MV>> cache) {
return new AtomicMapCache<K, MK, MV>(cache);
return new AtomicMapCache<>(cache);
}
}
);
Expand Down
Expand Up @@ -5,7 +5,6 @@
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;

public class DeployedMergePolicyFactoryService implements Service<DeployedMergePolicyFactory> {
Expand All @@ -15,7 +14,7 @@ public class DeployedMergePolicyFactoryService implements Service<DeployedMergeP
private final DeployedMergePolicyFactory factory = new DeployedMergePolicyFactory();

@Override
public void start(StartContext context) throws StartException {
public void start(StartContext context) {
InfinispanLogger.ROOT_LOGGER.debugf("Starting DeployedMergePolicyFactoryService");
}

Expand Down
Expand Up @@ -8,7 +8,6 @@
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.ServicesAttachment;
import org.jboss.modules.Module;
Expand All @@ -18,7 +17,7 @@
public class DeployedMergePolicyProcessor implements DeploymentUnitProcessor {

@Override
public void deploy(DeploymentPhaseContext ctx) throws DeploymentUnitProcessingException {
public void deploy(DeploymentPhaseContext ctx) {
DeploymentUnit deploymentUnit = ctx.getDeploymentUnit();
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES);
Expand Down
Expand Up @@ -10,7 +10,6 @@
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.ServicesAttachment;
import org.jboss.modules.Module;
Expand All @@ -26,7 +25,7 @@
public abstract class AbstractCacheStoreExtensionProcessor<T> implements DeploymentUnitProcessor {

@Override
public void deploy(DeploymentPhaseContext ctx) throws DeploymentUnitProcessingException {
public void deploy(DeploymentPhaseContext ctx) {
DeploymentUnit deploymentUnit = ctx.getDeploymentUnit();
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES);
Expand Down
Expand Up @@ -11,7 +11,6 @@
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.ServicesAttachment;
import org.jboss.as.server.deployment.module.ModuleDependency;
Expand All @@ -32,7 +31,7 @@ public class ServerExtensionDependenciesProcessor implements DeploymentUnitProce
private static final ModuleIdentifier TASKS_API = ModuleIdentifier.create("org.infinispan.tasks.api");

@Override
public void deploy(DeploymentPhaseContext ctx) throws DeploymentUnitProcessingException {
public void deploy(DeploymentPhaseContext ctx) {
DeploymentUnit deploymentUnit = ctx.getDeploymentUnit();
if (hasServerTaskExtensions(deploymentUnit)) {
addDependencies(deploymentUnit, API, TASKS_API);
Expand Down
Expand Up @@ -29,7 +29,7 @@ public class DeployedCacheStoreFactory implements CacheStoreFactory {
public <T> T createInstance(StoreConfiguration cfg) {
if (cfg instanceof DeployedStoreConfiguration) {
DeployedStoreConfiguration deployedConfiguration = (DeployedStoreConfiguration) cfg;
DeployedCacheStoreMetadata deployedCacheStoreMetadata = null;
DeployedCacheStoreMetadata deployedCacheStoreMetadata;
try {
InfinispanLogger.ROOT_LOGGER.debug(String.format("Waiting for deployment of Custom Cache Store (%s).", deployedConfiguration.getCustomStoreClassName()));
deployedCacheStoreMetadata = getPromise(deployedConfiguration.getCustomStoreClassName()).get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
Expand Down
Expand Up @@ -5,7 +5,6 @@
import org.jboss.msc.service.Service;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.service.StartContext;
import org.jboss.msc.service.StartException;
import org.jboss.msc.service.StopContext;

/**
Expand All @@ -20,7 +19,7 @@ public class DeployedCacheStoreFactoryService implements Service<CacheStoreFacto
private final DeployedCacheStoreFactory internalImplementation = new DeployedCacheStoreFactory();

@Override
public void start(StartContext context) throws StartException {
public void start(StartContext context) {
InfinispanLogger.ROOT_LOGGER.debugf("Starting DeployedCacheStoreFactoryService " + internalImplementation);
}

Expand Down

0 comments on commit ffb861d

Please sign in to comment.