Package com.hazelcast.partition

Examples of com.hazelcast.partition.InternalPartitionService


        return result;
    }

    @Override
    public Collection<Integer> getPartitions() {
        InternalPartitionService partitionService = getClientEngine().getPartitionService();
        int partitions = partitionService.getPartitionCount();
        int capacity = Math.min(partitions, keys.size()); //todo: is there better way to estimate size?
        Set<Integer> partitionIds = new HashSet<Integer>(capacity);

        Iterator<Data> iterator = keys.iterator();
        while (iterator.hasNext() && partitionIds.size() < partitions){
            Data key = iterator.next();
            partitionIds.add(partitionService.getPartitionId(key));
        }
        return partitionIds;
    }
View Full Code Here


    @Override
    public void writeResponse(ManagementCenterService mcs, ObjectDataOutput dos) throws Exception {
        Runtime runtime = Runtime.getRuntime();
        RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
        InternalPartitionService partitionService = mcs.getHazelcastInstance().node.getPartitionService();

        Map<String, String> properties = new LinkedHashMap<String, String>();
        properties.put("hazelcast.cl_version", mcs.getHazelcastInstance().node.getBuildInfo().getVersion());
        properties.put("date.cl_startTime", Long.toString(runtimeMxBean.getStartTime()));
        properties.put("seconds.cl_upTime", Long.toString(runtimeMxBean.getUptime()));
        properties.put("memory.cl_freeMemory", Long.toString(runtime.freeMemory()));
        properties.put("memory.cl_totalMemory", Long.toString(runtime.totalMemory()));
        properties.put("memory.cl_maxMemory", Long.toString(runtime.maxMemory()));
        properties.put("return.hasOngoingMigration", Boolean.toString(partitionService.hasOnGoingMigration()));
        properties.put("data.cl_migrationTasksCount", Long.toString(partitionService.getMigrationQueueSize()));

        dos.writeInt(properties.size());

        for (Map.Entry<String, String> entry : properties.entrySet()) {
            dos.writeUTF(entry.getKey() + ":#" + entry.getValue());
View Full Code Here

    }

    @Override
    public void run() throws Exception {
        response = new MapEntrySet();
        final InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        final RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        final LocalMapStatsImpl mapStats = mapService.getLocalMapStatsImpl(name);
        MapEntrySimple entry;

        for (Data key : keys) {
            if (partitionService.getPartitionId(key) != getPartitionId())
                continue;
            long start = System.currentTimeMillis();
            Object objectKey = mapService.toObject(key);
            final Map.Entry<Data, Object> mapEntry = recordStore.getMapEntry(key);
            final Object valueBeforeProcess = mapEntry.getValue();
View Full Code Here

    @Override
    public void writeResponse(ManagementCenterService mcs, ObjectDataOutput dos) throws Exception {
        HazelcastInstanceImpl instance = mcs.getHazelcastInstance();
        Node node = instance.node;
        ClusterServiceImpl cluster = node.getClusterService();
        InternalPartitionService partitionService = node.partitionService;
        Collection<LockResource> lockedRecords = collectLockState(instance);
        Map<Address, Connection> connectionMap = node.connectionManager.getReadonlyConnectionMap();

        ClusterRuntimeState clusterRuntimeState = new ClusterRuntimeState(
                cluster.getMembers(),
                partitionService.getPartitions(),
                partitionService.getActiveMigrations(),
                connectionMap,
                lockedRecords);
        clusterRuntimeState.writeData(dos);
    }
View Full Code Here

        this.keys = keys;
    }

    @Override
    public void run() throws Exception {
        final InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        final RecordStore recordStore = mapService.getRecordStore(getPartitionId(), name);
        MapEntrySimple entry;

        for (Data key : keys) {
            if (partitionService.getPartitionId(key) != getPartitionId())
                continue;
            Object objectKey = mapService.toObject(key);
            final Map.Entry<Data, Object> mapEntry = recordStore.getMapEntry(key);
            final Object valueBeforeProcess = mapService.toObject(mapEntry.getValue());
            entry = new MapEntrySimple(objectKey, valueBeforeProcess);
View Full Code Here

        backupRecordInfos = new ArrayList<RecordInfo>();
        backupEntrySet = new ArrayList<Map.Entry<Data,Data>>();
        int partitionId = getPartitionId();
        RecordStore recordStore = mapService.getRecordStore(partitionId, name);
        Set<Map.Entry<Data, Data>> entries = entrySet.getEntrySet();
        InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        Set<Data> keysToInvalidate = new HashSet<Data>();
        for (Map.Entry<Data, Data> entry : entries) {
            Data dataKey = entry.getKey();
            Data dataValue = entry.getValue();
            if (partitionId == partitionService.getPartitionId(dataKey)) {
                Data dataOldValue = null;
                if (initialLoad) {
                    recordStore.putFromLoad(dataKey, dataValue, -1);
                } else {
                    dataOldValue = mapService.toData(recordStore.put(dataKey, dataValue, -1));
View Full Code Here

            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;
                    }
View Full Code Here

            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;
                    }
View Full Code Here

        }
        NodeEngine nodeEngine = getNodeEngine();
        // todo action for read-backup true is not well tested.
        if (getMapConfig().isReadBackupData()) {
            int backupCount = getMapConfig().getTotalBackupCount();
            InternalPartitionService partitionService = mapService.getNodeEngine().getPartitionService();
            for (int i = 0; i <= backupCount; i++) {
                int partitionId = partitionService.getPartitionId(key);
                InternalPartition partition = partitionService.getPartition(partitionId);
                if (nodeEngine.getThisAddress().equals(partition.getReplicaAddress(i))) {
                    Object val = mapService.getPartitionContainer(partitionId).getRecordStore(name).get(key);
                    if (val != null) {
                        mapService.interceptAfterGet(name, val);
                        // this serialization step is needed not to expose the object, see issue 1292
View Full Code Here

        return result;
    }

    private Collection<Integer> getPartitionsForKeys(Set<Data> keys) {
        InternalPartitionService partitionService = getNodeEngine().getPartitionService();
        int partitions = partitionService.getPartitionCount();
        int capacity = Math.min(partitions, keys.size()); //todo: is there better way to estimate size?
        Set<Integer> partitionIds = new HashSet<Integer>(capacity);

        Iterator<Data> iterator = keys.iterator();
        while (iterator.hasNext() && partitionIds.size() < partitions) {
            Data key = iterator.next();
            partitionIds.add(partitionService.getPartitionId(key));
        }
        return partitionIds;
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.partition.InternalPartitionService

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.