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


Java Data类代码示例

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


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

示例1: getAttributes

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
/**
 * Gets attributes.
 *
 * @param sessionId the session id
 * @return the attributes
 * @throws Exception the exception
 */
Set<Map.Entry<String, Object>> getAttributes(String sessionId) throws Exception {
    GetSessionStateEntryProcessor entryProcessor = new GetSessionStateEntryProcessor();
    SessionState sessionState = (SessionState) executeOnKey(sessionId, entryProcessor);
    if (sessionState == null) {
        return null;
    }
    Map<String, Data> dataAttributes = sessionState.getAttributes();
    Set<Map.Entry<String, Object>> attributes = new HashSet<Map.Entry<String, Object>>(dataAttributes.size());
    for (Map.Entry<String, Data> entry : dataAttributes.entrySet()) {
        String key = entry.getKey();
        Object value = sss.getSerializationService().toObject(entry.getValue());
        attributes.add(new MapEntrySimple<String, Object>(key, value));
    }
    return attributes;
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:23,代码来源:ClusteredSessionService.java

示例2: process

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
public Object process(Map.Entry<String, SessionState> entry) {
    SessionState sessionState = entry.getValue();
    if (sessionState == null) {
        sessionState = new SessionState();
    }
    for (Map.Entry<String, Data> attribute : attributes.entrySet()) {
        String name = attribute.getKey();
        Data value = attribute.getValue();
        if (value == null) {
            sessionState.getAttributes().remove(name);
        } else {
            sessionState.getAttributes().put(name, value);
        }
    }
    entry.setValue(sessionState);
    return Boolean.TRUE;
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:19,代码来源:SessionUpdateEntryProcessor.java

示例3: readInternal

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);

    jobId = in.readLong();
    executionId = in.readLong();
    coordinatorMemberListVersion = in.readInt();
    int count = in.readInt();
    participants = new HashSet<>();
    for (int i = 0; i < count; i++) {
        MemberInfo participant = new MemberInfo();
        participant.readData(in);
        participants.add(participant);
    }

    final Data planBlob = in.readData();
    planSupplier = () -> {
        JetService service = getService();
        ClassLoader cl = service.getClassLoader(jobId);
        return deserializeWithCustomClassLoader(getNodeEngine().getSerializationService(), cl, planBlob);
    };
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:23,代码来源:InitExecutionOperation.java

示例4: offerToSnapshot

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
public final boolean offerToSnapshot(@Nonnull Object key, @Nonnull Object value) {
    if (snapshotEdge == null) {
        throw new IllegalStateException("Outbox does not have snapshot queue");
    }

    // pendingSnapshotEntry is used to avoid duplicate serialization when the queue rejects the entry
    if (pendingSnapshotEntry == null) {
        // We serialize the key and value immediately to effectively clone them,
        // so the caller can modify them right after they are accepted by this method.
        Data sKey = serializationService.toData(key);
        Data sValue = serializationService.toData(value);
        pendingSnapshotEntry = entry(sKey, sValue);
    }

    boolean success = offer(snapshotEdge, pendingSnapshotEntry);
    if (success) {
        pendingSnapshotEntry = null;
    }
    return success;
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:22,代码来源:OutboxImpl.java

示例5: when_jobIsCompleted_then_jobIsCleanedUp

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Test
public void when_jobIsCompleted_then_jobIsCleanedUp() {
    long jobId = uploadResourcesForNewJob();
    Data dag = createDAGData();
    JobRecord jobRecord = createJobRecord(jobId, dag);
    jobRepository.putNewJobRecord(jobRecord);
    long executionId1 = jobRepository.newExecutionId(jobId);
    long executionId2 = jobRepository.newExecutionId(jobId);
    JobResult jobResult = new JobResult(jobId, jobConfig, "uuid", jobRecord.getCreationTime(),
            System.currentTimeMillis(), null);
    instance.getMap(JobRepository.JOB_RESULTS_MAP_NAME).put(jobId, jobResult);

    jobRepository.cleanup(emptySet());

    assertNull(jobRepository.getJobRecord(jobId));
    assertTrue(jobRepository.getJobResources(jobId).isEmpty());
    assertFalse(jobIds.containsKey(executionId1));
    assertFalse(jobIds.containsKey(executionId2));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:20,代码来源:JobRepositoryTest.java

示例6: when_jobIsRunning_then_expiredJobIsNotCleanedUp

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Test
public void when_jobIsRunning_then_expiredJobIsNotCleanedUp() {
    long jobId = uploadResourcesForNewJob();
    Data dag = createDAGData();
    JobRecord jobRecord = createJobRecord(jobId, dag);
    jobRepository.putNewJobRecord(jobRecord);
    long executionId1 = jobRepository.newExecutionId(jobId);
    long executionId2 = jobRepository.newExecutionId(jobId);

    sleepUntilJobExpires();

    jobRepository.cleanup(singleton(jobId));

    assertNotNull(jobRepository.getJobRecord(jobId));
    assertFalse(jobRepository.getJobResources(jobId).isEmpty());
    assertTrue(jobIds.containsKey(executionId1));
    assertTrue(jobIds.containsKey(executionId2));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:19,代码来源:JobRepositoryTest.java

示例7: when_jobRecordIsPresentForExpiredJob_then_jobIsNotCleanedUp

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Test
public void when_jobRecordIsPresentForExpiredJob_then_jobIsNotCleanedUp() {
    long jobId = uploadResourcesForNewJob();
    Data dag = createDAGData();
    JobRecord jobRecord = createJobRecord(jobId, dag);
    jobRepository.putNewJobRecord(jobRecord);
    long executionId1 = jobRepository.newExecutionId(jobId);
    long executionId2 = jobRepository.newExecutionId(jobId);

    sleepUntilJobExpires();

    jobRepository.cleanup(emptySet());

    assertNotNull(jobRepository.getJobRecord(jobId));
    assertFalse(jobRepository.getJobResources(jobId).isEmpty());
    assertTrue(jobIds.containsKey(executionId1));
    assertTrue(jobIds.containsKey(executionId2));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:19,代码来源:JobRepositoryTest.java

示例8: removeCachedObject

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
public <T> T removeCachedObject(String cacheName, Object key, boolean convert) {
	RecordStore<?> cache = getRecordStore(key, cacheName);
	if (cache == null) {
		// nothing stored in this partition yet
		return null;
	}
	
	Data dKey = nodeEngine.toData(key);
	// will it remove backups?!
	Object data = cache.remove(dKey);
	if (data != null) {
		if (convert) {
			data = nodeEngine.toObject(data);
		}
	}
	return (T) data;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:18,代码来源:DataDistributionService.java

示例9: addAll

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
protected Map<Long, Data> addAll(List<Data> valueList) {
    final int size = valueList.size();
    final Map<Long, Data> map = new HashMap<Long, Data>(size);
    List<CollectionItem> list = new ArrayList<CollectionItem>(size);
    for (Data value : valueList) {
        final long itemId = nextId();
        final CollectionItem item = new OrderedCollectionItem(itemId, value);
        if (!getCollection().contains(item)) {
            list.add(item);
            map.put(itemId, value);
        }
    }
    getCollection().addAll(list);

    return map;
}
 
开发者ID:buremba,项目名称:hazelcast-modules,代码行数:18,代码来源:TreeSetContainer.java

示例10: submitToPartitionOwner

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
private <T> ScheduledFuture<T> submitToPartitionOwner(Callable<T> task, int partitionId, long delay, long period, boolean fixedRate) {
        if (task == null) {
            throw new NullPointerException("task can't be null");
        }
        if (isShutdown()) {
            throw new RejectedExecutionException(getRejectionMessage());
        }
        NodeEngine nodeEngine = getNodeEngine();
        Data taskData = nodeEngine.toData(task);
        String uuid = buildRandomUuidString();
        String name = getName();
        ScheduledCallableTaskOperation op = new ScheduledCallableTaskOperation(name, uuid, taskData, delay, period, fixedRate);
        ICompletableFuture future = invoke(partitionId, op);
        return new ScheduledDelegatingFuture<T>(future, nodeEngine.getSerializationService(), delay);
//        return new CancellableDelegatingFuture<T>(future, nodeEngine, uuid, partitionId);
    }
 
开发者ID:gurbuzali,项目名称:scheduled-executor,代码行数:17,代码来源:ScheduledExecutorProxy.java

示例11: writeData

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
public void writeData(ObjectDataOutput out) throws IOException {
    out.writeInt(attributes.size());
    for (Map.Entry<String, Data> entry : attributes.entrySet()) {
        out.writeUTF(entry.getKey());
        out.writeData(entry.getValue());
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:9,代码来源:SessionState.java

示例12: toString

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
public String toString() {
    StringBuilder sb = new StringBuilder("SessionState {");
    sb.append(", attributes=" + ((attributes == null) ? 0 : attributes.size()));
    if (attributes != null) {
        for (Map.Entry<String, Data> entry : attributes.entrySet()) {
            Data data = entry.getValue();
            int len = (data == null) ? 0 : data.dataSize();
            sb.append("\n\t");
            sb.append(entry.getKey() + "[" + len + "]");
        }
    }
    sb.append("\n}");
    return sb.toString();
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:16,代码来源:SessionState.java

示例13: process

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
public Data process(Map.Entry<String, SessionState> entry) {
    SessionState sessionState = entry.getValue();
    if (sessionState == null) {
        return null;
    }
    entry.setValue(sessionState);
    return sessionState.getAttributes().get(attributeName);
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:10,代码来源:GetAttributeEntryProcessor.java

示例14: readData

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
public void readData(ObjectDataInput in) throws IOException {
    int attCount = in.readInt();
    attributes = new HashMap<String, Data>(attCount);
    for (int i = 0; i < attCount; i++) {
        attributes.put(in.readUTF(), in.readData());
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:9,代码来源:SessionUpdateEntryProcessor.java

示例15: writeInternal

import com.hazelcast.nio.serialization.Data; //导入依赖的package包/类
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
    super.writeInternal(out);

    out.writeLong(jobId);
    out.writeLong(executionId);
    out.writeInt(coordinatorMemberListVersion);
    out.writeInt(participants.size());
    for (MemberInfo participant : participants) {
        participant.writeData(out);
    }
    Data planBlob = getNodeEngine().getSerializationService().toData(planSupplier.get());
    out.writeData(planBlob);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:15,代码来源:InitExecutionOperation.java


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