private void createMemberState(MemberStateImpl memberState) { final Node node = factory.node; memberState.setAddress(node.getThisAddress()); memberState.getMemberHealthStats().setOutOfMemory(node.isOutOfMemory()); memberState.getMemberHealthStats().setActive(node.isActive()); memberState .getMemberHealthStats() .setServiceThreadStats(node.getCpuUtilization().serviceThread); memberState.getMemberHealthStats().setOutThreadStats(node.getCpuUtilization().outThread); memberState.getMemberHealthStats().setInThreadStats(node.getCpuUtilization().inThread); PartitionService partitionService = factory.getPartitionService(); Set<Partition> partitions = partitionService.getPartitions(); memberState.clearPartitions(); for (Partition partition : partitions) { if (partition.getOwner() != null && partition.getOwner().localMember()) { memberState.addPartition(partition.getPartitionId()); } } Collection<HazelcastInstanceAwareInstance> proxyObjects = new ArrayList<HazelcastInstanceAwareInstance>(factory.getProxies()); createMemState(memberState, proxyObjects.iterator(), InstanceType.MAP); createMemState(memberState, proxyObjects.iterator(), InstanceType.QUEUE); createMemState(memberState, proxyObjects.iterator(), InstanceType.TOPIC); createRuntimeProps(memberState); // uncomment when client changes are made // createMemState(memberState, proxyObjects.iterator(), InstanceType.ATOMIC_LONG); // createMemState(memberState, proxyObjects.iterator(), InstanceType.COUNT_DOWN_LATCH); // createMemState(memberState, proxyObjects.iterator(), InstanceType.SEMAPHORE); }
void metodConvector() { String[] comandList = ConcreteCommand.myFile; Stack<Double> stack = new Stack<Double>(); for (int i = 0; i < count; i++) { String[] s = comandList[i].split(" "); String st = comandList[i]; FactoryImpl c = new FactoryImpl(); Command p = c.getCommand(s[0]); p.execute(stack, st); } }
public OutlineNode getOutline(int resourceId, String linkLabel) throws ZenoException { List articles = new ArrayList(); Article art = (Article) factory.loadResource(resourceId); articles.add(art); List nodes = getOutline(articles, linkLabel, -1); return (OutlineNode) nodes.get(0); }
public void kill() { synchronized (lifecycleLock) { fireLifecycleEvent(SHUTTING_DOWN); FactoryImpl.kill(factory); fireLifecycleEvent(SHUTDOWN); } }
public void shutdown() { synchronized (lifecycleLock) { fireLifecycleEvent(SHUTTING_DOWN); FactoryImpl.shutdown(factory); fireLifecycleEvent(SHUTDOWN); } }
public byte[] changeWebServerUrlOverCluster(String groupName, String groupPass, String newUrl) { try { GroupConfig groupConfig = factory.getConfig().getGroupConfig(); if (!(groupConfig.getName().equals(groupName) && groupConfig.getPassword().equals(groupPass))) return HttpCommand.RES_403; ManagementCenterConfigCallable callable = new ManagementCenterConfigCallable(newUrl); callable.setHazelcastInstance(factory); Set<Member> members = factory.getCluster().getMembers(); MultiTask<Void> task = new MultiTask<Void>(callable, members); ExecutorService executorService = factory.getExecutorService(); executorService.execute(task); } catch (Throwable throwable) { logger.log(Level.WARNING, "New web server url cannot be assigned.", throwable); return HttpCommand.RES_500; } return HttpCommand.RES_204; }
Collection callOnMembers(Set<Address> addresses, Callable callable) { Set<Member> allMembers = factory.getCluster().getMembers(); Set<Member> selectedMembers = new HashSet<Member>(addresses.size()); for (Member member : allMembers) { if (addresses.contains(((MemberImpl) member).getAddress())) { selectedMembers.add(member); } } return callOnMembers0(selectedMembers, callable); }
Object call(Address address, Callable callable) { Set<Member> members = factory.getCluster().getMembers(); for (Member member : members) { if (address.equals(((MemberImpl) member).getAddress())) { DistributedTask task = new DistributedTask(callable, member); return executeTaskAndGet(task); } } return null; }
public TimedMemberState getTimedMemberState() { if (running.get()) { final MemberStateImpl memberState = new MemberStateImpl(); createMemberState(memberState); GroupConfig groupConfig = factory.getConfig().getGroupConfig(); TimedMemberState timedMemberState = new TimedMemberState(); timedMemberState.setMaster(factory.node.isMaster()); if (timedMemberState.getMaster()) { timedMemberState.setMemberList(new ArrayList<String>()); Set<Member> memberSet = factory.getCluster().getMembers(); for (Member member : memberSet) { MemberImpl memberImpl = (MemberImpl) member; Address address = memberImpl.getAddress(); timedMemberState.getMemberList().add(address.getHost() + ":" + address.getPort()); } } timedMemberState.setMemberState(memberState); timedMemberState.setClusterName(groupConfig.getName()); timedMemberState.setInstanceNames(getLongInstanceNames()); return timedMemberState; } return null; }
private Set<String> getLongInstanceNames() { Set<String> setLongInstanceNames = new HashSet<String>(maxVisibleInstanceCount); Collection<HazelcastInstanceAwareInstance> proxyObjects = new ArrayList<HazelcastInstanceAwareInstance>(factory.getProxies()); collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.MAP); collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.QUEUE); collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.TOPIC); // uncomment when client changes are made // collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), // InstanceType.ATOMIC_NUMBER); // collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), // InstanceType.COUNT_DOWN_LATCH); // collectInstanceNames(setLongInstanceNames, proxyObjects.iterator(), InstanceType.SEMAPHORE); return setLongInstanceNames; }
private Object executeTaskAndGet(final DistributedTask task) { try { factory.getExecutorService().execute(task); try { return task.get(3, TimeUnit.SECONDS); } catch (Throwable e) { logger.log(Level.FINEST, e.getMessage(), e); return null; } } catch (Throwable e) { if (running.get() && factory.node.isActive()) { logger.log(Level.WARNING, e.getMessage(), e); } return null; } }
public ManagementCenterService(FactoryImpl factoryImpl) { this.factory = factoryImpl; logger = factory.node.getLogger(ManagementCenterService.class.getName()); managementCenterConfig = factory.node.config.getManagementCenterConfig(); if (managementCenterConfig == null) { throw new IllegalStateException("ManagementCenterConfig should not be null!"); } factory.getLifecycleService().addLifecycleListener(this); this.instanceFilterMap = new StatsInstanceFilter(factoryImpl.node.getGroupProperties().MC_MAP_EXCLUDES.getString()); this.instanceFilterQueue = new StatsInstanceFilter( factoryImpl.node.getGroupProperties().MC_QUEUE_EXCLUDES.getString()); this.instanceFilterTopic = new StatsInstanceFilter( factoryImpl.node.getGroupProperties().MC_TOPIC_EXCLUDES.getString()); this.instanceFilterAtomicNumber = new StatsInstanceFilter( factoryImpl.node.getGroupProperties().MC_ATOMIC_NUMBER_EXCLUDES.getString()); this.instanceFilterCountDownLatch = new StatsInstanceFilter( factoryImpl.node.getGroupProperties().MC_COUNT_DOWN_LATCH_EXCLUDES.getString()); this.instanceFilterSemaphore = new StatsInstanceFilter( factoryImpl.node.getGroupProperties().MC_SEMAPHORE_EXCLUDES.getString()); maxVisibleInstanceCount = factory.node.groupProperties.MC_MAX_INSTANCE_COUNT.getInteger(); commandHandler = new ConsoleCommandHandler(factory); String tmpWebServerUrl = managementCenterConfig != null ? managementCenterConfig.getUrl() : null; webServerUrl = tmpWebServerUrl != null ? (!tmpWebServerUrl.endsWith("/") ? tmpWebServerUrl + '/' : tmpWebServerUrl) : tmpWebServerUrl; updateIntervalMs = (managementCenterConfig != null && managementCenterConfig.getUpdateInterval() > 0) ? managementCenterConfig.getUpdateInterval() * 1000 : 5000; taskPoller = new TaskPoller(); stateSender = new StateSender(); }
Collection callOnAllMembers(Callable callable) { Set<Member> members = factory.getCluster().getMembers(); return callOnMembers0(members, callable); }