Package com.hazelcast.spi

Examples of com.hazelcast.spi.NodeEngine


        super(name, function);
    }

    @Override
    public void run() throws Exception {
        NodeEngine nodeEngine = getNodeEngine();
        IFunction f = nodeEngine.toObject(function);
        ReferenceWrapper reference = getReference();

        Object input = nodeEngine.toObject(reference.get());
        response = input;
        //noinspection unchecked
        Object output = f.apply(input);
        shouldBackup = !isEquals(input, output);
        if (shouldBackup) {
            backup = nodeEngine.toData(output);
            reference.set(backup);
        }
    }
View Full Code Here


        this.function = function;
    }

    @Override
    public void run() throws Exception {
        NodeEngine nodeEngine = getNodeEngine();
        IFunction f = nodeEngine.toObject(function);
        ReferenceWrapper reference = getReference();

        Object input = nodeEngine.toObject(reference.get());
        //noinspection unchecked
        Object output = f.apply(input);
        returnValue = nodeEngine.toData(output);
    }
View Full Code Here

        super(name, function);
    }

    @Override
    public void run() throws Exception {
        NodeEngine nodeEngine = getNodeEngine();
        IFunction f = nodeEngine.toObject(function);
        ReferenceWrapper reference = getReference();

        Object input = nodeEngine.toObject(reference.get());
        //noinspection unchecked
        Object output = f.apply(input);
        shouldBackup = true;
        backup = nodeEngine.toData(output);
        reference.set(backup);
        response = output;
    }
View Full Code Here

        super(name, function);
    }

    @Override
    public void run() throws Exception {
        NodeEngine nodeEngine = getNodeEngine();
        IFunction f = nodeEngine.toObject(function);
        ReferenceWrapper reference = getReference();

        Object input = nodeEngine.toObject(reference.get());
        //noinspection unchecked
        Object output = f.apply(input);
        shouldBackup = !isEquals(input, output);
        if (shouldBackup) {
            backup = nodeEngine.toData(output);
            reference.set(backup);
        }
    }
View Full Code Here

                }
            }
        }

        private void evictMap(MapContainer mapContainer) {
            final NodeEngine nodeEngine = mapService.getNodeEngine();
            final MapConfig mapConfig = mapContainer.getMapConfig();
            for (int i = 0; i < ExecutorConfig.DEFAULT_POOL_SIZE; i++) {
                final EvictRunner runner = new EvictRunner(mapConfig, i);
                nodeEngine.getExecutionService().execute(EXECUTOR_NAME, runner);
            }
        }
View Full Code Here

            int nodeTotalSize = 0;
            final MapService mapService = MapEvictionManager.this.mapService;
            final MaxSizeConfig maxSizeConfig = mapContainer.getMapConfig().getMaxSizeConfig();
            final int maxSize = getApproximateMaxSize(maxSizeConfig.getSize());
            final String mapName = mapContainer.getName();
            final NodeEngine nodeEngine = mapService.getNodeEngine();
            final InternalPartitionService partitionService = nodeEngine.getPartitionService();
            final int partitionCount = partitionService.getPartitionCount();
            for (int i = 0; i < partitionCount; i++) {
                final Address owner = partitionService.getPartitionOwner(i);
                if (nodeEngine.getThisAddress().equals(owner)) {
                    final PartitionContainer container = mapService.getPartitionContainer(i);
                    if (container == null) {
                        return false;
                    }
                    nodeTotalSize += container.getRecordStore(mapName).size();
View Full Code Here

        private boolean isEvictablePerPartition(final MapContainer mapContainer) {
            final MapService mapService = MapEvictionManager.this.mapService;
            final MaxSizeConfig maxSizeConfig = mapContainer.getMapConfig().getMaxSizeConfig();
            final int maxSize = getApproximateMaxSize(maxSizeConfig.getSize());
            final String mapName = mapContainer.getName();
            final NodeEngine nodeEngine = mapService.getNodeEngine();
            final InternalPartitionService partitionService = nodeEngine.getPartitionService();
            for (int i = 0; i < partitionService.getPartitionCount(); i++) {
                final Address owner = partitionService.getPartitionOwner(i);
                if (nodeEngine.getThisAddress().equals(owner)) {
                    final PartitionContainer container = mapService.getPartitionContainer(i);
                    if (container == null) {
                        return false;
                    }
                    final int size = container.getRecordStore(mapName).size();
View Full Code Here

        private long getUsedHeapSize(final MapContainer mapContainer) {
            long heapCost = 0L;
            final MapService mapService = MapEvictionManager.this.mapService;
            final String mapName = mapContainer.getName();
            final NodeEngine nodeEngine = mapService.getNodeEngine();
            final Address thisAddress = nodeEngine.getThisAddress();
            for (int i = 0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
                if (nodeEngine.getPartitionService().getPartition(i).isOwnerOrBackup(thisAddress)) {
                    final PartitionContainer container = mapService.getPartitionContainer(i);
                    if (container == null) {
                        return -1;
                    }
                    heapCost += container.getRecordStore(mapName).getHeapCost();
View Full Code Here

        public void run() {
            final MapConfig mapConfig = this.mapConfig;
            final String mapName = mapConfig.getName();
            final MapService mapService = MapEvictionManager.this.mapService;
            final NodeEngine nodeEngine = mapService.getNodeEngine();
            Set<Data> keysGatheredForNearCacheEviction = Collections.emptySet();
            for (int i = 0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
                if ((i % ExecutorConfig.DEFAULT_POOL_SIZE) != mod) {
                    continue;
                }
                final Address owner = nodeEngine.getPartitionService().getPartitionOwner(i);
                if (nodeEngine.getThisAddress().equals(owner)) {
                    final PartitionContainer pc = mapService.getPartitionContainer(i);
                    final RecordStore recordStore = pc.getRecordStore(mapName);
                    final Collection<Record> values = recordStore.getReadonlyRecordMap().values();
                    if (values.isEmpty()) {
                        continue;
                    }
                    final Object[][] evictableKeyValuePairs = getEvictableRecords(recordStore, mapConfig);
                    if (evictableKeyValuePairs.length == 0) {
                        continue;
                    }
                    final Set<Data> keySet = new HashSet<Data>(evictableKeyValuePairs.length);
                    for (final Object[] kvp : evictableKeyValuePairs) {
                        if (kvp[0] != null) {
                            keySet.add((Data) kvp[0]);
                        }
                    }
                    if (keySet.isEmpty()) {
                        continue;
                    }
                    keysGatheredForNearCacheEviction = new HashSet<Data>(keySet.size());
                    //add keys for near cache eviction.
                    keysGatheredForNearCacheEviction.addAll(keySet);
                    //prepare local "evict keys" operation.
                    EvictKeysOperation evictKeysOperation = new EvictKeysOperation(mapName, keySet);
                    evictKeysOperation.setNodeEngine(nodeEngine);
                    evictKeysOperation.setServiceName(MapService.SERVICE_NAME);
                    evictKeysOperation.setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler());
                    evictKeysOperation.setPartitionId(i);
                    OperationAccessor.setCallerAddress(evictKeysOperation, nodeEngine.getThisAddress());
                    nodeEngine.getOperationService().executeOperation(evictKeysOperation);
                    for (final Object[] kvp : evictableKeyValuePairs) {
                        if (kvp[0] != null) {
                            mapService.publishEvent(nodeEngine.getThisAddress(), mapName, EntryEventType.EVICTED,
                                    (Data) kvp[0], mapService.toData(kvp[1]), null);
                        }
                    }
                }
            }
View Full Code Here

    public void process(EntryTaskScheduler<Data, Object> scheduler, Collection<ScheduledEntry<Data, Object>> entries) {
        if (entries.isEmpty())
            return;

        NodeEngine nodeEngine = mapService.getNodeEngine();
        if (entries.size() == 1) {
            ScheduledEntry<Data, Object> entry = entries.iterator().next();
            int partitionId = nodeEngine.getPartitionService().getPartitionId(entry.getKey());
            // execute operation if the node is owner of the key (it can be backup)
            if (nodeEngine.getThisAddress().equals(nodeEngine.getPartitionService().getPartitionOwner(partitionId))) {
                Exception e = tryDelete(scheduler, entry);
                if (e != null) {
                    logger.severe(e);
                }
            }
        } else {
            Set keys = new HashSet();
            Exception e = null;
            for (ScheduledEntry<Data, Object> entry : entries) {
                int partitionId = nodeEngine.getPartitionService().getPartitionId(entry.getKey());
                // execute operation if the node is owner of the key (it can be backup)
                if (nodeEngine.getThisAddress().equals(nodeEngine.getPartitionService().getPartitionOwner(partitionId))) {
                    keys.add(mapService.toObject(entry.getKey()));
                }
            }
            try {
                mapContainer.getStore().deleteAll(keys);
View Full Code Here

TOP

Related Classes of com.hazelcast.spi.NodeEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.