Skip to content

Commit

Permalink
ISPN-6423 Move clustering.sync.replTimeout to clustering.remoteTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
danberindei committed Mar 22, 2016
1 parent 77591d1 commit ac7be83
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 7 deletions.
Expand Up @@ -4,6 +4,8 @@
import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeSet;

import java.util.concurrent.TimeUnit;


/**
* Defines clustered characteristics of the cache.
Expand All @@ -13,6 +15,8 @@
*/
public class ClusteringConfiguration {
public static final AttributeDefinition<CacheMode> CACHE_MODE = AttributeDefinition.builder("cacheMode", CacheMode.LOCAL).immutable().build();
public static final AttributeDefinition<Long> REMOTE_TIMEOUT =
AttributeDefinition.builder("remoteTimeout", TimeUnit.SECONDS.toMillis(15)).build();

static AttributeSet attributeDefinitionSet() {
return new AttributeSet(ClusteringConfiguration.class, CACHE_MODE);
Expand Down Expand Up @@ -45,6 +49,22 @@ public CacheMode cacheMode() {
return cacheMode.get();
}

/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*/
public long remoteTimeout() {
return syncConfiguration.replTimeout();
}

/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*/
public void remoteTimeout(long timeoutMillis) {
syncConfiguration.replTimeout(timeoutMillis);
}

/**
* Configures cluster's behaviour in the presence of partitions or node failures.
*/
Expand All @@ -53,7 +73,6 @@ public PartitionHandlingConfiguration partitionHandling() {
}

public String cacheModeString() {

return cacheMode() == null ? "none" : cacheMode().toString();
}

Expand All @@ -76,7 +95,10 @@ public L1Configuration l1() {
/**
* Configure sync sub element. Once this method is invoked users cannot subsequently invoke
* <code>async()</code> as two are mutually exclusive
*
* @deprecated Since 9.0, the {@code replTimeout} attribute is now in {@link ClusteringConfiguration}.
*/
@Deprecated
public SyncConfiguration sync() {
return syncConfiguration;
}
Expand Down
Expand Up @@ -7,8 +7,11 @@
import org.infinispan.util.logging.LogFactory;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import static org.infinispan.configuration.cache.ClusteringConfiguration.CACHE_MODE;
import static org.infinispan.configuration.cache.ClusteringConfiguration.REMOTE_TIMEOUT;

/**
* Defines clustered characteristics of the cache.
*
Expand Down Expand Up @@ -48,6 +51,24 @@ public CacheMode cacheMode() {
return attributes.attribute(CACHE_MODE).get();
}

/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*/
public ClusteringConfigurationBuilder remoteTimeout(long l) {
attributes.attribute(REMOTE_TIMEOUT).set(l);
return this;
}

/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*/
public ClusteringConfigurationBuilder remoteTimeout(long l, TimeUnit unit) {
return remoteTimeout(unit.toMillis(l));
}


/**
* Configure hash sub element
*/
Expand Down
Expand Up @@ -23,7 +23,10 @@ public interface ClusteringConfigurationChildBuilder extends ConfigurationChildB
* If configured all communications are synchronous, in that whenever a thread sends a message
* sent over the wire, it blocks until it receives an acknowledgment from the recipient.
* SyncConfig is mutually exclusive with the AsyncConfig.
*
* @deprecated Since 9.0, the {@code replTimeout} attribute is now in {@link ClusteringConfigurationBuilder}.
*/
@Deprecated
SyncConfigurationBuilder sync();

/**
Expand Down
Expand Up @@ -10,37 +10,50 @@
* If configured all communications are synchronous, in that whenever a thread sends a message sent
* over the wire, it blocks until it receives an acknowledgment from the recipient. SyncConfig is
* mutually exclusive with the AsyncConfig.
*
* @deprecated Since 9.0, the {@code replTimeout} attribute is now {@code ClusteringConfiguration.remoteTimeout}.
*/
@Deprecated
public class SyncConfiguration {

/**
* @deprecated Since 9.0, replaced with {@link ClusteringConfiguration#REMOTE_TIMEOUT}
*/
@Deprecated
public static final AttributeDefinition<Long> REPL_TIMEOUT = AttributeDefinition.builder("replTimeout", TimeUnit.SECONDS.toMillis(15)).build();

static AttributeSet attributeDefinitionSet() {
return new AttributeSet(SyncConfiguration.class.getSimpleName(), REPL_TIMEOUT);
return new AttributeSet(SyncConfiguration.class.getSimpleName(), ClusteringConfiguration.REMOTE_TIMEOUT);
}

private final Attribute<Long> replTimeout;
private final Attribute<Long> remoteTimeout;
private final AttributeSet attributes;

SyncConfiguration(AttributeSet attributes) {
this.attributes = attributes.checkProtection();
replTimeout = attributes.attribute(REPL_TIMEOUT);
remoteTimeout = attributes.attribute(ClusteringConfiguration.REMOTE_TIMEOUT);
}

/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*
* @deprecated Since 9.0, please use {@link ClusteringConfiguration#replTimeout()} instead.
*/
@Deprecated
public long replTimeout() {
return replTimeout.get();
return remoteTimeout.get();
}

/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*
* @deprecated Since 9.0, please use {@link ClusteringConfiguration#replTimeout(long)} instead.
*/
@Deprecated
public SyncConfiguration replTimeout(long l) {
replTimeout.set(l);
remoteTimeout.set(l);
return this;
}

Expand Down
Expand Up @@ -12,7 +12,10 @@
* If configured all communications are synchronous, in that whenever a thread sends a message sent
* over the wire, it blocks until it receives an acknowledgment from the recipient. SyncConfig is
* mutually exclusive with the AsyncConfig.
*
* @deprecated Since 9.0, the {@code replTimeout} attribute is now {@code ClusteringConfigurationBuilder.remoteTimeout}.
*/
@Deprecated
public class SyncConfigurationBuilder extends AbstractClusteringConfigurationChildBuilder implements Builder<SyncConfiguration> {
private final AttributeSet attributes;

Expand All @@ -24,16 +27,22 @@ protected SyncConfigurationBuilder(ClusteringConfigurationBuilder builder) {
/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*
* @deprecated Since 9.0, please use {@link ClusteringConfigurationBuilder#remoteTimeout(long)}.
*/
@Deprecated
public SyncConfigurationBuilder replTimeout(long l) {
attributes.attribute(REPL_TIMEOUT).set(l);
attributes.attribute(ClusteringConfiguration.REMOTE_TIMEOUT).set(l);
return this;
}

/**
* This is the timeout used to wait for an acknowledgment when making a remote call, after which
* the call is aborted and an exception is thrown.
*
* @deprecated Since 9.0, please use {@link ClusteringConfigurationBuilder#remoteTimeout(long, TimeUnit)}.
*/
@Deprecated
public SyncConfigurationBuilder replTimeout(long l, TimeUnit unit) {
return replTimeout(unit.toMillis(l));
}
Expand Down

0 comments on commit ac7be83

Please sign in to comment.