当前位置: 首页>>代码示例>>Java>>正文


Java Address类代码示例

本文整理汇总了Java中akka.actor.Address的典型用法代码示例。如果您正苦于以下问题:Java Address类的具体用法?Java Address怎么用?Java Address使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Address类属于akka.actor包,在下文中一共展示了Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ActorContext

import akka.actor.Address; //导入依赖的package包/类
public ActorContext(ActorSystem actorSystem, ActorRef shardManager,
        ClusterWrapper clusterWrapper, Configuration configuration,
        DatastoreContext datastoreContext, PrimaryShardInfoFutureCache primaryShardInfoCache) {
    this.actorSystem = actorSystem;
    this.shardManager = shardManager;
    this.clusterWrapper = clusterWrapper;
    this.configuration = configuration;
    this.datastoreContext = datastoreContext;
    this.dispatchers = new Dispatchers(actorSystem.dispatchers());
    this.primaryShardInfoCache = primaryShardInfoCache;

    final LogicalDatastoreType convertedType =
            LogicalDatastoreType.valueOf(datastoreContext.getLogicalStoreType().name());
    this.shardStrategyFactory = new ShardStrategyFactory(configuration, convertedType);

    setCachedProperties();

    Address selfAddress = clusterWrapper.getSelfAddress();
    if (selfAddress != null && !selfAddress.host().isEmpty()) {
        selfAddressHostPort = selfAddress.host().get() + ":" + selfAddress.port().get();
    } else {
        selfAddressHostPort = null;
    }

}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:ActorContext.java

示例2: testResolve

import akka.actor.Address; //导入依赖的package包/类
@Test
public void testResolve() {
    String type = "config";
    ShardPeerAddressResolver resolver = new ShardPeerAddressResolver(type, MEMBER_1);

    MemberName memberName = MEMBER_2;
    String peerId = ShardIdentifier.create("default", memberName, type).toString();

    assertEquals("resolve", null, resolver.resolve(peerId));

    Address address = new Address("tcp", "system");
    resolver.addPeerAddress(memberName, address);

    String shardAddress = resolver.getShardActorAddress("default", memberName);
    assertEquals("getShardActorAddress", address.toString() + "/user/shardmanager-" + type + "/"
            + memberName.getName() + "-shard-default-" + type, shardAddress);

    assertEquals("resolve", shardAddress, resolver.resolve(peerId));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ShardPeerAddressResolverTest.java

示例3: testGetShardManagerPeerActorAddresses

import akka.actor.Address; //导入依赖的package包/类
@Test
public void testGetShardManagerPeerActorAddresses() {
    ShardPeerAddressResolver resolver = new ShardPeerAddressResolver("config", MEMBER_1);

    resolver.addPeerAddress(MEMBER_1, new Address("tcp", "system1"));

    Address address2 = new Address("tcp", "system2");
    resolver.addPeerAddress(MEMBER_2, address2);

    Address address3 = new Address("tcp", "system3");
    resolver.addPeerAddress(MEMBER_3, address3);

    Collection<String> peerAddresses = resolver.getShardManagerPeerActorAddresses();
    assertEquals("getShardManagerPeerActorAddresses", Sets.newHashSet(
            address2.toString() + "/user/shardmanager-config",
            address3.toString() + "/user/shardmanager-config"), Sets.newHashSet(peerAddresses));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:ShardPeerAddressResolverTest.java

示例4: findRpcByName

import akka.actor.Address; //导入依赖的package包/类
@Override
public Map<String, String> findRpcByName(final String name) {
    RoutingTable localTable = rpcRegistry.getLocalData();
    // Get all RPCs from local bucket
    Map<String, String> rpcMap = new HashMap<>(getRpcMemberMapByName(localTable, name, LOCAL_CONSTANT));

    // Get all RPCs from remote bucket
    Map<Address, Bucket<RoutingTable>> buckets = rpcRegistry.getRemoteBuckets();
    for (Entry<Address, Bucket<RoutingTable>> entry : buckets.entrySet()) {
        RoutingTable table = entry.getValue().getData();
        rpcMap.putAll(getRpcMemberMapByName(table, name, entry.getKey().toString()));
    }

    log.debug("list of RPCs {} searched by name {}", rpcMap, name);
    return rpcMap;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:RemoteRpcRegistryMXBeanImpl.java

示例5: receiveGossipTick

import akka.actor.Address; //导入依赖的package包/类
/**
 * Sends Gossip status to other members in the cluster.
 * <br>
 * 1. If there are no member, ignore the tick. <br>
 * 2. If there's only 1 member, send gossip status (bucket versions) to it. <br>
 * 3. If there are more than one member, randomly pick one and send gossip status (bucket versions) to it.
 */
@VisibleForTesting
void receiveGossipTick() {
    final Address address;
    switch (clusterMembers.size()) {
        case 0:
            //no members to send gossip status to
            return;
        case 1:
            address = clusterMembers.get(0);
            break;
        default:
            final int randomIndex = ThreadLocalRandom.current().nextInt(0, clusterMembers.size());
            address = clusterMembers.get(randomIndex);
            break;
    }

    LOG.trace("Gossiping to [{}]", address);
    getLocalStatusAndSendTo(Verify.verifyNotNull(peers.get(address)));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:27,代码来源:Gossiper.java

示例6: getBucketsByMembers

import akka.actor.Address; //导入依赖的package包/类
/**
 * Helper to collect buckets for requested members.
 *
 * @param members requested members
 */
private void getBucketsByMembers(final Collection<Address> members) {
    Map<Address, Bucket<T>> buckets = new HashMap<>();

    //first add the local bucket if asked
    if (members.contains(selfAddress)) {
        buckets.put(selfAddress, getLocalBucket().snapshot());
    }

    //then get buckets for requested remote nodes
    for (Address address : members) {
        if (remoteBuckets.containsKey(address)) {
            buckets.put(address, remoteBuckets.get(address));
        }
    }

    getSender().tell(buckets, getSelf());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:BucketStoreActor.java

示例7: onBucketsUpdated

import akka.actor.Address; //导入依赖的package包/类
@Override
protected void onBucketsUpdated(final Map<Address, Bucket<RoutingTable>> buckets) {
    final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = new HashMap<>(buckets.size());

    for (Entry<Address, Bucket<RoutingTable>> e : buckets.entrySet()) {
        final RoutingTable table = e.getValue().getData();

        final Collection<DOMRpcIdentifier> rpcs = table.getRoutes();
        endpoints.put(e.getKey(), rpcs.isEmpty() ? Optional.empty()
                : Optional.of(new RemoteRpcEndpoint(table.getRpcInvoker(), rpcs)));
    }

    if (!endpoints.isEmpty()) {
        rpcRegistrar.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender());
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:RpcRegistry.java

示例8: verifyEmptyBucket

import akka.actor.Address; //导入依赖的package包/类
private void verifyEmptyBucket(final JavaTestKit testKit, final ActorRef registry, final Address address)
        throws AssertionError {
    Map<Address, Bucket<RoutingTable>> buckets;
    int numTries = 0;
    while (true) {
        buckets = retrieveBuckets(registry1, testKit, address);

        try {
            verifyBucket(buckets.get(address), Collections.emptyList());
            break;
        } catch (AssertionError e) {
            if (++numTries >= 50) {
                throw e;
            }
        }

        Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:RpcRegistryTest.java

示例9: assertEndpoints

import akka.actor.Address; //导入依赖的package包/类
private static void assertEndpoints(final UpdateRemoteEndpoints msg, final Address address,
        final JavaTestKit invoker) {
    final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = msg.getEndpoints();
    Assert.assertEquals(1, endpoints.size());

    final Optional<RemoteRpcEndpoint> maybeEndpoint = endpoints.get(address);
    Assert.assertNotNull(maybeEndpoint);
    Assert.assertTrue(maybeEndpoint.isPresent());

    final RemoteRpcEndpoint endpoint = maybeEndpoint.get();
    final ActorRef router = endpoint.getRouter();
    Assert.assertNotNull(router);

    router.tell("hello", ActorRef.noSender());
    final String s = invoker.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), String.class);
    Assert.assertEquals("hello", s);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:RpcRegistryTest.java

示例10: main

import akka.actor.Address; //导入依赖的package包/类
/**
 * @param args
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException {
	ActorSystem _system = ActorSystem.create("RemoteRouteeRouterExample");
	
	Address addr1 = new Address("akka", "remotesys", "127.0.0.1", 2552);
	Address addr2 = new Address("akka", "remotesys", "127.0.0.1", 2552);

	Address[] addresses = new Address[] { addr1, addr2 };
	
	ActorRef randomRouter = _system.actorOf(new Props(MsgEchoActor.class)
			.withRouter(new RemoteRouterConfig(new RandomRouter(5),addresses)));

	for (int i = 1; i <= 10; i++) {
		// sends randomly to actors
		randomRouter.tell(i);
	}
	_system.shutdown();
}
 
开发者ID:rokumar7,项目名称:trial,代码行数:22,代码来源:Example2.java

示例11: remoteActorCreationDemo1

import akka.actor.Address; //导入依赖的package包/类
@SuppressWarnings("serial")
public void remoteActorCreationDemo1() {
	log.info("Creating a actor using remote deployment mechanism");

	// create the address object that points to the remote server
	Address addr = new Address("akka", "ServerSys", "127.0.0.1", 2552);

	// creating the ServerActor on the specified remote server
	final ActorRef serverActor = system.actorOf(new Props(ServerActor.class)
			.withDeploy(new Deploy(new RemoteScope(addr))));

	// create a local actor and pass the reference of the remote actor
	actor = system.actorOf(new Props(new UntypedActorFactory() {
		public UntypedActor create() {
			return new ClientActor(serverActor);
		}
	}));
	// send a message to the local client actor
	actor.tell("Start-RemoteActorCreationDemo1");
}
 
开发者ID:rokumar7,项目名称:trial,代码行数:21,代码来源:ClientActorSystem.java

示例12: remoteActorCreationDemo2

import akka.actor.Address; //导入依赖的package包/类
@SuppressWarnings("serial")
public void remoteActorCreationDemo2() {
	log.info("Creating a actor with remote deployment");

	// alternate way to create the address object that points to the remote
	// server
	Address addr = AddressFromURIString
			.parse("akka://[email protected]:2552");

	// creating the ServerActor on the specified remote server
	final ActorRef serverActor = system.actorOf(new Props(ServerActor.class)
			.withDeploy(new Deploy(new RemoteScope(addr))));

	// create a local actor and pass the reference of the remote actor
	actor = system.actorOf(new Props(new UntypedActorFactory() {
		public UntypedActor create() {
			return new ClientActor(serverActor);
		}
	}));
	// send a message to the local client actor
	actor.tell("Start-RemoteActorCreationDemo2");
}
 
开发者ID:rokumar7,项目名称:trial,代码行数:23,代码来源:ClientActorSystem.java

示例13: addWorkerRoute

import akka.actor.Address; //导入依赖的package包/类
/**
 * Add the new worker to the router mechanism
 * 
 * @param address
 */
private void addWorkerRoute(String address) {

	// send the stop message to all the worker actors
	if (workerRouterActor != null) {
		for (int i = 0; i < workerAddressMap.size(); i++)
			workerRouterActor.tell("STOP");
	}

	// add the address to the Map
	workerAddressMap.put(address, AddressFromURIString.parse(address));

	Address[] addressNodes = new Address[workerAddressMap.size()];

	Address[] workerAddress = workerAddressMap.values().toArray(
			addressNodes);

	// update the workerRouter actor with the information on all workers
	workerRouterActor = getContext().system().actorOf(
			new Props(WorkerActor.class).withRouter(new RemoteRouterConfig(
					new RoundRobinRouter(workerAddress.length),
					workerAddress)));

}
 
开发者ID:rokumar7,项目名称:trial,代码行数:29,代码来源:JobControllerActor.java

示例14: MyUnboundedPriorityMailbox

import akka.actor.Address; //导入依赖的package包/类
public MyUnboundedPriorityMailbox(ActorSystem.Settings settings,
		Config config) {

	// Creating a new PriorityGenerator,
	super(new PriorityGenerator() {
		@Override
		public int gen(Object message) {
			if (message instanceof Address)
				return 0; // Worker Registration messages should be
							// treated
							// with highest priority
			else if (message.equals(PoisonPill.getInstance()))
				return 3; // PoisonPill when no other left
			else
				return 1; // By default they go with medium priority
		}
	});
}
 
开发者ID:rokumar7,项目名称:trial,代码行数:19,代码来源:WorkServerActorSystem.java

示例15: path

import akka.actor.Address; //导入依赖的package包/类
private ActorPath path(String host) {
  final String[] split = host.split(":");
  final String hostname = split[0];
  final int port = Integer.parseInt(split[1]);

  final Address actorSystemAddress = new Address("akka.tcp", "concierge", hostname, port);
  return RootActorPath.apply(actorSystemAddress, "/").child("user");
}
 
开发者ID:marnikitta,项目名称:Concierge,代码行数:9,代码来源:ConciergeConfig.java


注:本文中的akka.actor.Address类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。