<failOnError>true</failOnError>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
}
protected abstract ClientActorBehavior<?> initialBehavior(ClientActorContext context);
+
+ protected abstract ClientActorConfig getClientActorConfig();
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Inocybe Technologies and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.access.client;
+
+/**
+ * Interface for client actor configuration parameters.
+ *
+ * @author Thomas Pantelis
+ */
+public interface ClientActorConfig {
+ /**
+ * Returns the maximum size in bytes for a message slice when fragmenting messages thru the akka remoting framework.
+ *
+ * @return the maximum size in bytes
+ */
+ int getMaximumMessageSliceSize();
+
+ /**
+ * Returns the threshold in bytes before switching from storing in memory to buffering to a file when streaming
+ * large amounts of data.
+ *
+ * @return the threshold in bytes
+ */
+ int getFileBackedStreamingThreshold();
+
+ /**
+ * Returns the directory in which to create temporary files.
+ *
+ * @return the directory name
+ */
+ String getTempFileDirectory();
+}
private final ExecutionContext executionContext;
private final ClientIdentifier identifier;
private final Scheduler scheduler;
+ private final ClientActorConfig config;
// Hidden to avoid subclassing
ClientActorContext(final ActorRef self, final Scheduler scheduler, final ExecutionContext executionContext,
- final String persistenceId, final ClientIdentifier identifier) {
+ final String persistenceId, final ClientIdentifier identifier, final ClientActorConfig config) {
super(self, persistenceId);
this.identifier = Preconditions.checkNotNull(identifier);
this.scheduler = Preconditions.checkNotNull(scheduler);
this.executionContext = Preconditions.checkNotNull(executionContext);
+ this.config = Preconditions.checkNotNull(config);
}
@Override
return identifier;
}
+ @Nonnull
+ public ClientActorConfig config() {
+ return config;
+ }
+
/**
* Return the time ticker for this {@link ClientActorContext}. This should be used for in all time-tracking
* done within a client actor. Subclasses of {@link ClientActorBehavior} are encouraged to use
ClientActorBehavior<?> createBehavior(final ClientIdentifier clientId) {
final ActorSystem system = actor.getContext().system();
final ClientActorContext context = new ClientActorContext(self(), system.scheduler(), system.dispatcher(),
- persistenceId(), clientId);
+ persistenceId(), clientId, actor.getClientActorConfig());
return actor.initialBehavior(context);
}
backendProbe = new TestProbe(system);
contextProbe = new TestProbe(system);
context = new ClientActorContext(contextProbe.ref(), system.scheduler(), system.dispatcher(),
- PERSISTENCE_ID, CLIENT_ID);
+ PERSISTENCE_ID, CLIENT_ID, AccessClientUtil.newMockClientActorConfig());
replyToProbe = new TestProbe(system);
connection = createConnection();
}
return new AbortLocalTransactionRequest(identifier, replyTo);
}
-}
\ No newline at end of file
+}
*/
package org.opendaylight.controller.cluster.access.client;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import akka.actor.ActorRef;
public static ClientActorContext createClientActorContext(final ActorSystem system, final ActorRef actor,
final ClientIdentifier id, final String persistenceId) {
- return spy(new ClientActorContext(actor, system.scheduler(), system.dispatcher(), persistenceId, id));
+
+ return spy(new ClientActorContext(actor, system.scheduler(), system.dispatcher(), persistenceId, id,
+ newMockClientActorConfig()));
+ }
+
+ public static ClientActorConfig newMockClientActorConfig() {
+ ClientActorConfig mockConfig = mock(ClientActorConfig.class);
+ doReturn(2_000_000).when(mockConfig).getMaximumMessageSliceSize();
+ doReturn(1_000_000_000).when(mockConfig).getFileBackedStreamingThreshold();
+ return mockConfig;
}
public static <T extends BackendInfo> ConnectedClientConnection<T> createConnectedConnection(
return new ConnectionEntry(request, callback, now);
}
-}
\ No newline at end of file
+}
return initialBehavior;
}
+ @Override
+ protected ClientActorConfig getClientActorConfig() {
+ return new ClientActorConfig() {
+ @Override
+ public String getTempFileDirectory() {
+ return null;
+ }
+
+ @Override
+ public int getMaximumMessageSliceSize() {
+ return 2000000;
+ }
+
+ @Override
+ public int getFileBackedStreamingThreshold() {
+ return 1000000000;
+ }
+ };
+ }
}
-}
\ No newline at end of file
+}
system = ActorSystem.apply();
probe = new TestProbe(system);
ctx = new ClientActorContext(probe.ref(), system.scheduler(), system.dispatcher(),
- PERSISTENCE_ID, CLIENT_ID);
+ PERSISTENCE_ID, CLIENT_ID, AccessClientUtil.newMockClientActorConfig());
}
@Test
<artifactId>cds-access-client</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>cds-access-client</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-cluster-admin-api</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>cds-access-client</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>cds-access-client</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>cds-dom-api</artifactId>
import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
import org.opendaylight.controller.cluster.access.client.AbstractClientActor;
+import org.opendaylight.controller.cluster.access.client.ClientActorConfig;
import org.opendaylight.controller.cluster.access.client.ClientActorContext;
import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
import org.opendaylight.controller.cluster.common.actor.ExplicitAsk;
this.actorContext = Preconditions.checkNotNull(actorContext);
}
+ @Override
+ protected ClientActorConfig getClientActorConfig() {
+ return actorContext.getDatastoreContext();
+ }
+
@Override
protected final AbstractDataStoreClientBehavior initialBehavior(final ClientActorContext context) {
return Verify.verifyNotNull(initialBehavior(context, actorContext));
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.text.WordUtils;
+import org.opendaylight.controller.cluster.access.client.ClientActorConfig;
import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader;
import org.opendaylight.controller.cluster.common.actor.FileAkkaConfigurationReader;
import org.opendaylight.controller.cluster.raft.ConfigParams;
*
* @author Thomas Pantelis
*/
-public class DatastoreContext {
+public class DatastoreContext implements ClientActorConfig {
public static final String METRICS_DOMAIN = "org.opendaylight.controller.cluster.datastore";
public static final Duration DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT = Duration.create(10, TimeUnit.MINUTES);
return shardManagerPersistenceId;
}
+ @Override
public String getTempFileDirectory() {
return raftConfig.getTempFileDirectory();
}
raftConfig.setTempFileDirectory(tempFileDirectory);
}
+ @Override
public int getFileBackedStreamingThreshold() {
return raftConfig.getFileBackedStreamingThreshold();
}
return useTellBasedProtocol;
}
+ @Override
public int getMaximumMessageSliceSize() {
return maximumMessageSliceSize;
}