- Fixed compile error in MeteringBehavior as signature of onReceive now
declares Throwable.
- Fixed intermittent failure in
ShardManagerGetSnapshotReplyActorTest#testGetSnapshotTimeout. On failure,
the actor would not get the ReceiveTimeout message from akka. However,
oddly the test didn't fail if just testGetSnapshotTimeout was run - it
would only fail if run with at least one of the other 2 tests. I tried
creating a different ActorSystem for each test but that didn't fix it.
I finally narrowed it down to creating the actors via the TestActorFactory
although the exact reason is unknown. The tests don't really need to use
the TestActorFactory so I remove its use.
- Fixed intermittent failure in
ShardTransactionTest#testShardTransactionInactivity. This was the same issue
as the ShardManagerGetSnapshotReplyActorTest, i.e. the actor would not get
the ReceiveTimeout message when no other message was sent. I found the
TestActorFactory was again the culprit. I narrowed it down to the
verifyActorReady method which creates an ActorSelection and sends an
Identify message. This was put in to work around messages intermittently
going to dead letters shortly after actor creaton. It seems this code
somehow may interfere with the ReceiveTimeout functionality. So to workaround
this, I allowed the caller to elide the verifyActorReady call.
Change-Id: Ic8474def917414fa9bbe0f19b30b213f3052a1aa
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
*/
public ActorRef createActor(Props props) {
ActorRef actorRef = system.actorOf(props);
*/
public ActorRef createActor(Props props) {
ActorRef actorRef = system.actorOf(props);
- return addActor(actorRef);
+ return addActor(actorRef, true);
*/
public ActorRef createActor(Props props, String actorId) {
ActorRef actorRef = system.actorOf(props, actorId);
*/
public ActorRef createActor(Props props, String actorId) {
ActorRef actorRef = system.actorOf(props, actorId);
- return addActor(actorRef);
+ return addActor(actorRef, true);
+ }
+
+ /**
+ * Create a normal actor with the passed in name w/o verifying that the actor is ready.
+ *
+ * @param props the actor Props
+ * @param actorId name of actor
+ * @return the ActorRef
+ */
+ public ActorRef createActorNoVerify(Props props, String actorId) {
+ ActorRef actorRef = system.actorOf(props, actorId);
+ return addActor(actorRef, false);
@SuppressWarnings("unchecked")
public <T extends Actor> TestActorRef<T> createTestActor(Props props, String actorId) {
TestActorRef<T> actorRef = TestActorRef.create(system, props, actorId);
@SuppressWarnings("unchecked")
public <T extends Actor> TestActorRef<T> createTestActor(Props props, String actorId) {
TestActorRef<T> actorRef = TestActorRef.create(system, props, actorId);
- return (TestActorRef<T>) addActor(actorRef);
+ return (TestActorRef<T>) addActor(actorRef, true);
@SuppressWarnings("unchecked")
public <T extends Actor> TestActorRef<T> createTestActor(Props props) {
TestActorRef<T> actorRef = TestActorRef.create(system, props);
@SuppressWarnings("unchecked")
public <T extends Actor> TestActorRef<T> createTestActor(Props props) {
TestActorRef<T> actorRef = TestActorRef.create(system, props);
- return (TestActorRef<T>) addActor(actorRef);
+ return (TestActorRef<T>) addActor(actorRef, true);
- private <T extends ActorRef> ActorRef addActor(T actorRef) {
+ private <T extends ActorRef> ActorRef addActor(T actorRef, boolean verify) {
createdActors.add(actorRef);
createdActors.add(actorRef);
- verifyActorReady(actorRef);
+ if (verify) {
+ verifyActorReady(actorRef);
+ }
+
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.google.common.base.Preconditions;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
import org.opendaylight.controller.cluster.reporting.MetricsReporter;
/**
import org.opendaylight.controller.cluster.reporting.MetricsReporter;
/**
* @param message the message to process
* @throws Exception on message failure
*/
* @param message the message to process
* @throws Exception on message failure
*/
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void apply(final Object message) throws Exception {
final String messageType = message.getClass().getSimpleName();
@Override
public void apply(final Object message) throws Exception {
final String messageType = message.getClass().getSimpleName();
final Timer.Context context = msgProcessingTimer.time();
final Timer.Context contextByMsgType = msgProcessingTimerByMsgType.time();
final Timer.Context context = msgProcessingTimer.time();
final Timer.Context contextByMsgType = msgProcessingTimerByMsgType.time();
- meteredActor.onReceive(message);
-
- //stop timers
- contextByMsgType.stop();
- context.stop();
+ try {
+ meteredActor.onReceive(message);
+ } catch (Throwable e) {
+ Throwables.propagateIfPossible(e, Exception.class);
+ throw Throwables.propagate(e);
+ } finally {
+ //stop timers
+ contextByMsgType.stop();
+ context.stop();
+ }
final AbstractShardDataTreeTransaction<?> transaction, final String name) {
Props props = ShardTransaction.props(type, transaction, shard, datastoreContext,
shard.underlyingActor().getShardMBean());
final AbstractShardDataTreeTransaction<?> transaction, final String name) {
Props props = ShardTransaction.props(type, transaction, shard, datastoreContext,
shard.underlyingActor().getShardMBean());
- return actorFactory.createActor(props, name);
+ return actorFactory.createActorNoVerify(props, name);
}
private ReadOnlyShardDataTreeTransaction readOnlyTransaction() {
}
private ReadOnlyShardDataTreeTransaction readOnlyTransaction() {
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.Test;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
import org.junit.Test;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
-import org.opendaylight.controller.cluster.raft.TestActorFactory;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
import scala.concurrent.duration.Duration;
import scala.concurrent.duration.FiniteDuration;
import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
import scala.concurrent.duration.Duration;
import scala.concurrent.duration.FiniteDuration;
public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
private static final MemberName MEMBER_1 = MemberName.forName("member-1");
public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
private static final MemberName MEMBER_1 = MemberName.forName("member-1");
- private final TestActorFactory actorFactory = new TestActorFactory(getSystem());
-
- @After
- public void tearDown() {
- actorFactory.close();
- }
-
@Test
public void testSuccess() {
JavaTestKit kit = new JavaTestKit(getSystem());
byte[] shardManagerSnapshot = new byte[]{0,5,9};
@Test
public void testSuccess() {
JavaTestKit kit = new JavaTestKit(getSystem());
byte[] shardManagerSnapshot = new byte[]{0,5,9};
- ActorRef replyActor = actorFactory.createActor(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1", "shard2", "shard3"), "config",
- shardManagerSnapshot, kit.getRef(), "shard-manager", Duration.create(100, TimeUnit.SECONDS)),
- actorFactory.generateActorId("actor"));
+ ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
+ Arrays.asList("shard1", "shard2", "shard3"), "config", shardManagerSnapshot, kit.getRef(),
+ "shard-manager", Duration.create(100, TimeUnit.SECONDS)), "testSuccess");
JavaTestKit kit = new JavaTestKit(getSystem());
byte[] shardManagerSnapshot = new byte[]{0,5,9};
JavaTestKit kit = new JavaTestKit(getSystem());
byte[] shardManagerSnapshot = new byte[]{0,5,9};
- ActorRef replyActor = actorFactory.createActor(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1", "shard2"), "config",
- shardManagerSnapshot, kit.getRef(), "shard-manager", Duration.create(100, TimeUnit.SECONDS)),
- actorFactory.generateActorId("actor"));
+ ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
+ Arrays.asList("shard1", "shard2"), "config", shardManagerSnapshot, kit.getRef(), "shard-manager",
+ Duration.create(100, TimeUnit.SECONDS)), "testGetSnapshotFailureReply");
JavaTestKit kit = new JavaTestKit(getSystem());
byte[] shardManagerSnapshot = new byte[]{0,5,9};
JavaTestKit kit = new JavaTestKit(getSystem());
byte[] shardManagerSnapshot = new byte[]{0,5,9};
- ActorRef replyActor = actorFactory.createActor(ShardManagerGetSnapshotReplyActor.props(
- Arrays.asList("shard1"), "config",
- shardManagerSnapshot, kit.getRef(), "shard-manager", Duration.create(100, TimeUnit.MILLISECONDS)),
- actorFactory.generateActorId("actor"));
+ ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
+ Arrays.asList("shard1"), "config", shardManagerSnapshot, kit.getRef(), "shard-manager",
+ Duration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");