ActorUtils { public boolean isPathLocal(final String path) { if (Strings.isNullOrEmpty(path)) { return false; } int pathAtIndex = path.indexOf('@'); if (pathAtIndex == -1) { return true; } else if (selfAddressHostPort != null) { int slashIndex = path.indexOf('/', pathAtIndex); if (slashIndex == -1) { return false; } String hostPort = path.substring(pathAtIndex + 1, slashIndex); return hostPort.equals(selfAddressHostPort); } else { return false; } } ActorUtils(final ActorSystem actorSystem, final ActorRef shardManager,
            final ClusterWrapper clusterWrapper, final Configuration configuration);  ActorUtils(final ActorSystem actorSystem, final ActorRef shardManager,
            final ClusterWrapper clusterWrapper, final Configuration configuration,
            final DatastoreContext datastoreContext, final PrimaryShardInfoFutureCache primaryShardInfoCache); DatastoreContext getDatastoreContext(); ActorSystem getActorSystem(); ActorRef getShardManager(); ActorSelection actorSelection(final String actorPath); ActorSelection actorSelection(final ActorPath actorPath); void setSchemaContext(final EffectiveModelContext schemaContext); void setDatastoreContext(final DatastoreContextFactory contextFactory); EffectiveModelContext getSchemaContext(); Future<PrimaryShardInfo> findPrimaryShardAsync(final String shardName); Optional<ActorRef> findLocalShard(final String shardName); Future<ActorRef> findLocalShardAsync(final String shardName); @SuppressWarnings("checkstyle:IllegalCatch") Object executeOperation(final ActorRef actor, final Object message); @SuppressWarnings("checkstyle:IllegalCatch") Object executeOperation(final ActorSelection actor, final Object message); Future<Object> executeOperationAsync(final ActorRef actor, final Object message, final Timeout timeout); Future<Object> executeOperationAsync(final ActorSelection actor, final Object message,
            final Timeout timeout); Future<Object> executeOperationAsync(final ActorSelection actor, final Object message); void sendOperationAsync(final ActorSelection actor, final Object message); @SuppressWarnings("checkstyle:IllegalCatch") void shutdown(); ClusterWrapper getClusterWrapper(); MemberName getCurrentMemberName(); void broadcast(final Function<Short, Object> messageSupplier, final Class<?> messageClass); FiniteDuration getOperationDuration(); Timeout getOperationTimeout(); boolean isPathLocal(final String path); Timer getOperationTimer(final String operationName); Timer getOperationTimer(final String dataStoreType, final String operationName); String getDataStoreName(); double getTxCreationLimit(); void acquireTxCreationPermit(); Timeout getTransactionCommitOperationTimeout(); ExecutionContext getClientDispatcher(); String getNotificationDispatcherPath(); Configuration getConfiguration(); ShardStrategyFactory getShardStrategyFactory(); PrimaryShardInfoFutureCache getPrimaryShardInfoCache(); static final String BOUNDED_MAILBOX; static final String COMMIT; }
@Test public void testIsPathLocal() { MockClusterWrapper clusterWrapper = new MockClusterWrapper(); ActorUtils actorUtils = null; actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertFalse(actorUtils.isPathLocal(null)); assertFalse(actorUtils.isPathLocal("")); clusterWrapper.setSelfAddress(null); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertFalse(actorUtils.isPathLocal("")); clusterWrapper.setSelfAddress(new Address("akka", "test")); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertTrue(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "test")); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertTrue(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "test")); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertTrue(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertTrue(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "system")); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertFalse(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "test")); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertTrue(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertTrue(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertFalse(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertFalse(actorUtils.isPathLocal("akka: clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorUtils = new ActorUtils(getSystem(), null, clusterWrapper, mock(Configuration.class)); assertFalse(actorUtils.isPathLocal("akka: }