當前位置: 首頁>>代碼示例>>Java>>正文


Java Member類代碼示例

本文整理匯總了Java中com.hazelcast.core.Member的典型用法代碼示例。如果您正苦於以下問題:Java Member類的具體用法?Java Member怎麽用?Java Member使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Member類屬於com.hazelcast.core包,在下文中一共展示了Member類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createHazelcastInstance

import com.hazelcast.core.Member; //導入依賴的package包/類
/**
 * 
 */
private void createHazelcastInstance()
{
  hazelcast = Hazelcast.getOrCreateHazelcastInstance(hzConfig);
   Set<Member> members = hazelcast.getCluster().getMembers();
   
   int memberIdCnt = 0;
   for(Member m : members)
   {
     
     if(m.getStringAttribute(Configurator.NODE_INSTANCE_ID).equals(getInstanceId()))
     {
       memberIdCnt++;
     }
     if(memberIdCnt >= 2){
       stop();
       throw new IllegalStateException("Instance not allowed to join cluster as ["+getInstanceId()+"]. Duplicate name!");
     }
     
   }
   log.info("** Instance ["+getInstanceId()+"] joined cluster ["+hzConfig.getGroupConfig().getName()+"] successfully **");
}
 
開發者ID:javanotes,項目名稱:reactive-data,代碼行數:25,代碼來源:HazelcastInstanceProxy.java

示例2: distributedPropertyDidChange

import com.hazelcast.core.Member; //導入依賴的package包/類
@Override
public void distributedPropertyDidChange(Member member, Integer oldValue, Integer newValue)
{
	if (newValue == null)
	{
		return;
	}
	if (sneyNode instanceof TrainTracksApp)
	{
		oldValue = ((TrainTracksApp) sneyNode).getNumOfCorners();
		if (oldValue < newValue)
		{
			for (int i = 0; i < (newValue - oldValue); i++)
			{
				((TrainTracksApp) sneyNode).addCorner();
			}
		}
		else if ((oldValue > newValue) && (newValue >= 0))
		{
			for (int i = 0; i < (oldValue - newValue); i++)
			{
				((TrainTracksApp) sneyNode).removeCorner();
			}
		}
	}
}
 
開發者ID:synergynet,項目名稱:synergynet3.1,代碼行數:27,代碼來源:EarlyYearsSync.java

示例3: initCalculatorCollectionSync

import com.hazelcast.core.Member; //導入依賴的package包/類
/**
 * Inits the calculator collection sync.
 */
private void initCalculatorCollectionSync()
{
	List<String> participants = getNamesListFromParticipantList(tableClusterData.getParticipantListControlVariable().getValue());
	calculatorCollectionManager.setAvailableCalculatorCollection(participants);

	tableClusterData.getParticipantListControlVariable().registerChangeListener(new DistributedPropertyChangedAction<List<Participant>>()
	{
		@Override
		public void distributedPropertyDidChange(Member m, List<Participant> oldValue, List<Participant> newValue)
		{
			log.fine("Update received for participant list: " + newValue);
			List<String> names = getNamesListFromParticipantList(newValue);
			calculatorCollectionManager.setAvailableCalculatorCollection(names);
		}
	});
}
 
開發者ID:synergynet,項目名稱:synergynet3.1,代碼行數:20,代碼來源:CalculatorCollectionSync.java

示例4: ExpressionSession

import com.hazelcast.core.Member; //導入依賴的package包/類
/**
 * Instantiates a new expression session.
 *
 * @param dataCluster
 *            the data cluster
 */
public ExpressionSession(NumberNetStudentTableClusteredData dataCluster)
{
	listeners = new ArrayList<IExpressionSessionChangeListener>();

	targetValueFormatter = new DecimalFormat();
	targetValueFormatter.setDecimalSeparatorAlwaysShown(false);
	targetValueFormatter.setMaximumFractionDigits(10);

	expressions = new ArrayList<Expression>();

	dataCluster.getTargetValueControlVariable().registerChangeListener(new DistributedPropertyChangedAction<Double>()
	{
		@Override
		public void distributedPropertyDidChange(Member member, Double oldValue, Double newValue)
		{
			log.fine("Target value changed from " + oldValue + " to " + newValue);
			setTarget(newValue);
		}
	});
}
 
開發者ID:synergynet,項目名稱:synergynet3.1,代碼行數:27,代碼來源:ExpressionSession.java

示例5: createAndGetItemAddedAction

import com.hazelcast.core.Member; //導入依賴的package包/類
/**
 * Creates the and get item added action.
 *
 * @return the item added action
 */
private ItemAddedAction<String, Expression> createAndGetItemAddedAction()
{
	itemAddedAction = new ItemAddedAction<String, Expression>()
	{
		@Override
		public void itemAddedToCollection(IMap<String, Expression> collection, String itemKey, Expression itemValue, Member member)
		{
			if (member.localMember())
			{
				return;
			}
			addExpressionFromAlreadyExistingEntryInDistributedMap(itemValue);
		}
	};
	return itemAddedAction;
}
 
開發者ID:synergynet,項目名稱:synergynet3.1,代碼行數:22,代碼來源:ExpressionSession.java

示例6: createAndGetItemRemovedAction

import com.hazelcast.core.Member; //導入依賴的package包/類
/**
 * Creates the and get item removed action.
 *
 * @return the item removed action
 */
private ItemRemovedAction<String, Expression> createAndGetItemRemovedAction()
{
	itemRemovedAction = new ItemRemovedAction<String, Expression>()
	{
		@Override
		public void itemRemovedFromCollection(IMap<String, Expression> collection, String itemKey, Expression itemValue, Member member)
		{
			if (member.localMember())
			{
				return;
			}
			removeExpressionFromSession(itemValue, true);
		}
	};
	return itemRemovedAction;
}
 
開發者ID:synergynet,項目名稱:synergynet3.1,代碼行數:22,代碼來源:ExpressionSession.java

示例7: distributedPropertyDidChange

import com.hazelcast.core.Member; //導入依賴的package包/類
@Override
public void distributedPropertyDidChange(Member member, Integer oldValue, Integer newValue)
{
	if (newValue == null)
	{
		return;
	}
	if (sneyNode instanceof TrainTracksTrackedApp)
	{
		oldValue = ((TrainTracksTrackedApp) sneyNode).getNumOfCorners();
		if (oldValue < newValue)
		{
			for (int i = 0; i < (newValue - oldValue); i++)
			{
				((TrainTracksTrackedApp) sneyNode).addCorner();
			}
		}
		else if ((oldValue > newValue) && (newValue >= 0))
		{
			for (int i = 0; i < (oldValue - newValue); i++)
			{
				((TrainTracksTrackedApp) sneyNode).removeCorner();
			}
		}
	}
}
 
開發者ID:synergynet,項目名稱:synergynet3.1,代碼行數:27,代碼來源:EarlyYearsSync.java

示例8: multiTask

import com.hazelcast.core.Member; //導入依賴的package包/類
/**
 * Submits a task to multiple members of the Hazelcast task cluster.
 * 
 * @param task
 *        The task
 * @param where
 *        A {@link MemberSelector}, an {@link Iterable} of {@link Member}, a
 *        string (comma-separated member tags), or null for all members
 * @return A map of members to futures for the task
 */
@SuppressWarnings("unchecked")
private <T> Map<Member, Future<T>> multiTask( SerializableApplicationTask<T> task, Object where )
{
	IExecutorService executor = getHazelcastExecutorService();

	if( where instanceof String )
		return executor.submitToMembers( task, new TaggedMembers( HAZELCAST_MEMBER_TAGS_ATTRIBUTE, (String) where ) );
	else if( where instanceof MemberSelector )
		return executor.submitToMembers( task, (MemberSelector) where );
	else if( where instanceof Collection )
		return executor.submitToMembers( task, (Collection<Member>) where );
	else if( where instanceof Iterable )
	{
		ArrayList<Member> members = new ArrayList<Member>();
		for( Member member : (Iterable<Member>) where )
			members.add( member );
		return executor.submitToMembers( task, members );
	}
	else
		return executor.submitToAllMembers( task );
}
 
開發者ID:tliron,項目名稱:prudence,代碼行數:32,代碼來源:DistributedApplicationService.java

示例9: getTaskMember

import com.hazelcast.core.Member; //導入依賴的package包/類
private Member getTaskMember( String tagsAttribute, String requiredTags )
{
	String[] requiredTagsArray = requiredTags.split( "," );
	Set<String> requiredTagsSet = new HashSet<String>();
	for( String tag : requiredTagsArray )
		requiredTagsSet.add( tag );

	for( Member member : getHazelcastTaskInstance().getCluster().getMembers() )
	{
		String tags = (String) member.getAttributes().get( tagsAttribute );
		if( tags != null )
		{
			String[] existingsTags = tags.split( "," );
			for( String existingTag : existingsTags )
				if( requiredTagsSet.contains( existingTag ) )
					return member;
		}
	}

	return null;
}
 
開發者ID:tliron,項目名稱:prudence,代碼行數:22,代碼來源:DistributedApplicationService.java

示例10: testBackpressure

import com.hazelcast.core.Member; //導入依賴的package包/類
@Test
public void testBackpressure() throws Exception {
    DAG dag = new DAG();

    final int member1Port = jet1.getCluster().getLocalMember().getAddress().getPort();
    final Member member2 = jet2.getCluster().getLocalMember();
    final int ptionOwnedByMember2 =
            jet1.getHazelcastInstance().getPartitionService()
                .getPartitions().stream()
                .filter(p -> p.getOwner().equals(member2))
                .map(Partition::getPartitionId)
                .findAny()
                .orElseThrow(() -> new RuntimeException("Can't find a partition owned by member " + jet2));
    Vertex source = dag.newVertex("source", ProcessorMetaSupplier.of((Address address) ->
            ProcessorSupplier.of(address.getPort() == member1Port ? GenerateP::new : noopP())
    ));
    Vertex hiccup = dag.newVertex("hiccup", HiccupP::new);
    Vertex sink = dag.newVertex("sink", SinkProcessors.writeMapP("counts"));

    dag.edge(between(source, hiccup)
            .distributed().partitioned(wholeItem(), (x, y) -> ptionOwnedByMember2))
       .edge(between(hiccup, sink));

    jet1.newJob(dag).join();
    assertCounts(jet1.getMap("counts"));
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:27,代碼來源:BackpressureTest.java

示例11: init

import com.hazelcast.core.Member; //導入依賴的package包/類
@Override
public void init(@Nonnull Context context) {
    logger = context.jetInstance().getHazelcastInstance().getLoggingService().getLogger(ReadHdfsP.class);
    try {
        int totalParallelism = context.totalParallelism();
        InputFormat inputFormat = jobConf.getInputFormat();
        InputSplit[] splits = inputFormat.getSplits(jobConf, totalParallelism);
        IndexedInputSplit[] indexedInputSplits = new IndexedInputSplit[splits.length];
        Arrays.setAll(indexedInputSplits, i -> new IndexedInputSplit(i, splits[i]));

        Address[] addrs = context.jetInstance().getCluster().getMembers()
                .stream().map(Member::getAddress).toArray(Address[]::new);
        assigned = assignSplitsToMembers(indexedInputSplits, addrs);
        printAssignments(assigned);
    } catch (IOException e) {
        throw rethrow(e);
    }
}
 
開發者ID:hazelcast,項目名稱:hazelcast-jet,代碼行數:19,代碼來源:ReadHdfsP.java

示例12: test

import com.hazelcast.core.Member; //導入依賴的package包/類
private void test(final HazelcastInstance hazelcast1, final HazelcastInstance hazelcast2) {
    final IAtomicLong counterA = hazelcast1.getAtomicLong("counter-a");
    final long countA = counterA.incrementAndGet();
    LOG.log(INFO, "expecting {0} = {1}", new Object[]{counterA.get(), hazelcast1.getAtomicLong("counter-a").get()});
    assertThat(countA, is(hazelcast1.getAtomicLong("counter-a").get()));

    assertThat(hazelcast2.getAtomicLong("counter-a").get(), is(hazelcast1.getAtomicLong("counter-a").get()));

    final Member member2 = hazelcast2.getCluster().getLocalMember();
    LOG.log(INFO, member2.getAttributes().entrySet().stream()
            .map(entry -> entry.getKey() + " -> " + entry.getValue() + " : " + entry.getValue().getClass().getName())
            .collect(Collectors.joining("\n", "member 2 attributes\n", "\n"))
    );

    assertThat(member2.getStringAttribute("string"), is("hello"));
    assertThat(member2.getIntAttribute("int"), is(1));
    assertThat(member2.getBooleanAttribute("bool"), is(true));
}
 
開發者ID:runrightfast,項目名稱:runrightfast-vertx,代碼行數:19,代碼來源:HazelcastConfigFactoryTest.java

示例13: updateJpaAddresses

import com.hazelcast.core.Member; //導入依賴的package包/類
@Override
public void updateJpaAddresses(ConfigurationDao dao) {
	StringBuilder sb = new StringBuilder();
	String delim = "";
	for (Member m : hazelcast.getCluster().getMembers()) {
		sb.append(delim).append(m.getAddress().getHost());
		delim = ";";
	}
	if (Strings.isEmpty(delim)) {
		sb.append("localhost");
	}
	try {
		dao.updateClusterAddresses(sb.toString());
	} catch (UnknownHostException e) {
		log.error("Uexpected exception while updating JPA addresses", e);
		throw new WicketRuntimeException(e);
	}
}
 
開發者ID:apache,項目名稱:openmeetings,代碼行數:19,代碼來源:Application.java

示例14: getUsageStatistics

import com.hazelcast.core.Member; //導入依賴的package包/類
public TabularData getUsageStatistics(Callable<TabularData> statsTask, StatsAggregator aggregator) {
	logger.trace("getUsageStatistics.enter; going to collect stats for schema: {}", schemaName);

	int cnt = 0;
	TabularData result = null;
	Map<Member, Future<TabularData>> futures = execService.submitToAllMembers(statsTask);
	for (Map.Entry<Member, Future<TabularData>> entry: futures.entrySet()) {
		try {
			TabularData stats = entry.getValue().get();
			logger.trace("getUsageStatistics; got stats: {}, from member {}", stats, entry.getKey());
			result = JMXUtils.aggregateStats(stats, result, aggregator);
			logger.trace("getUsageStatistics; got aggregated result: {}", result);
			cnt++;
		} catch (InterruptedException | ExecutionException ex) {
			logger.error("getUsageStatistics.error: " + ex.getMessage(), ex);
		}
	}
	logger.trace("getUsageStatistics.exit; got stats from {} nodes", cnt);
	return result;
}
 
開發者ID:dsukhoroslov,項目名稱:bagri,代碼行數:21,代碼來源:SchemaFeatureManagement.java

示例15: find

import com.hazelcast.core.Member; //導入依賴的package包/類
public LocalNodeConfig find(Member member) throws Exception {
	InetAddress inetAddress = member.getSocketAddress().getAddress();
	
	String memberIp = inetAddress.getHostAddress();
	String fullHostName = inetAddress.getCanonicalHostName();
	
	int hazelcastPort = member.getSocketAddress().getPort();
	
	Set<HazelcastNode> matches = new HashSet<>();
	matches.add(new HazelcastNode(memberIp, hazelcastPort));
	matches.add(new HazelcastNode(fullHostName, hazelcastPort));
	
	for (HazelcastNode node : nodes.keySet()) {
		if (matches.contains(node)) {
			return nodes.get(node);
		}
		
	}
	
	throw new Exception("Member with memberIp <" + memberIp + "> and fullHostName <" + fullHostName + "> and hazelcast port <" + hazelcastPort
					+ "> not found in cluster membership.  Correctly register the machine with server address or ip that all machines can resolve");
	
}
 
開發者ID:lumongo,項目名稱:lumongo,代碼行數:24,代碼來源:Nodes.java


注:本文中的com.hazelcast.core.Member類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。