Java 类com.hazelcast.core.EntryView 实例源码

项目:hazelcast-hibernate5    文件:VersionAwareMapMergePolicy.java   
@Override
public Object merge(final String mapName, final EntryView mergingEntry, final EntryView existingEntry) {
    final Object existingValue = existingEntry != null ? existingEntry.getValue() : null;
    final Object mergingValue = mergingEntry.getValue();
    if (existingValue != null && existingValue instanceof CacheEntry
            && mergingValue != null && mergingValue instanceof CacheEntry) {

        final CacheEntry existingCacheEntry = (CacheEntry) existingValue;
        final CacheEntry mergingCacheEntry = (CacheEntry) mergingValue;
        final Object mergingVersionObject = mergingCacheEntry.getVersion();
        final Object existingVersionObject = existingCacheEntry.getVersion();
        if (mergingVersionObject != null && existingVersionObject != null
                && mergingVersionObject instanceof Comparable && existingVersionObject instanceof Comparable) {

            final Comparable mergingVersion = (Comparable) mergingVersionObject;
            final Comparable existingVersion = (Comparable) existingVersionObject;

            if (mergingVersion.compareTo(existingVersion) > 0) {
                return mergingValue;
            } else {
                return existingValue;
            }
        }
    }
    return mergingValue;
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicy.java   
public Object merge(String mapName, EntryView mergingEntry, EntryView existingEntry) {
    final Object existingValue = existingEntry != null ? existingEntry.getValue() : null;
    final Object mergingValue = mergingEntry.getValue();
    if (existingValue != null && existingValue instanceof CacheEntry
            && mergingValue != null && mergingValue instanceof CacheEntry) {

        final CacheEntry existingCacheEntry = (CacheEntry) existingValue;
        final CacheEntry mergingCacheEntry = (CacheEntry) mergingValue;
        final Object mergingVersionObject = mergingCacheEntry.getVersion();
        final Object existingVersionObject = existingCacheEntry.getVersion();
        if (mergingVersionObject != null && existingVersionObject != null
                && mergingVersionObject instanceof Comparable && existingVersionObject instanceof Comparable) {

            final Comparable mergingVersion = (Comparable) mergingVersionObject;
            final Comparable existingVersion = (Comparable) existingVersionObject;

            if (mergingVersion.compareTo(existingVersion) > 0) {
                return mergingValue;
            } else {
                return existingValue;
            }
        }
    }
    return mergingValue;
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicy.java   
public Object merge(String mapName, EntryView mergingEntry, EntryView existingEntry) {
    final Object existingValue = existingEntry != null ? existingEntry.getValue() : null;
    final Object mergingValue = mergingEntry.getValue();
    if (existingValue != null && existingValue instanceof CacheEntry
            && mergingValue != null && mergingValue instanceof CacheEntry) {

        final CacheEntry existingCacheEntry = (CacheEntry) existingValue;
        final CacheEntry mergingCacheEntry = (CacheEntry) mergingValue;
        final Object mergingVersionObject = mergingCacheEntry.getVersion();
        final Object existingVersionObject = existingCacheEntry.getVersion();
        if (mergingVersionObject != null && existingVersionObject != null
                && mergingVersionObject instanceof Comparable && existingVersionObject instanceof Comparable) {

            final Comparable mergingVersion = (Comparable) mergingVersionObject;
            final Comparable existingVersion = (Comparable) existingVersionObject;

            if (mergingVersion.compareTo(existingVersion) > 0) {
                return mergingValue;
            } else {
                return existingValue;
            }
        }
    }
    return mergingValue;
}
项目:hazelcast-hibernate5    文件:IMapRegionCache.java   
@Override
public long getSizeInMemory() {
    long size = 0;
    for (final Object key : map.keySet()) {
        final EntryView entry = map.getEntryView(key);
        if (entry != null) {
            size += entry.getCost();
        }
    }
    return size;
}
项目:hazelcast-hibernate5    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingUptodate() {
    CacheEntry existing = cacheEntryWithVersion(versionOld);
    CacheEntry merging = cacheEntryWithVersion(versionNew);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(merging, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate5    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingStale() {
    CacheEntry existing = cacheEntryWithVersion(versionNew);
    CacheEntry merging = cacheEntryWithVersion(versionOld);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(existing, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate5    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingNull() {
    CacheEntry existing = null;
    CacheEntry merging = cacheEntryWithVersion(versionNew);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(merging, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate5    文件:VersionAwareMapMergePolicyTest.java   
private EntryView entryWithGivenValue(Object value) {
    EntryView entryView = mock(EntryView.class);
    try {
        when(entryView.getValue()).thenReturn(value);
        return entryView;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

}
项目:eet.osslite.cz    文件:HazelcastAdminRest.java   
@RequestMapping(method = RequestMethod.GET, path = "/statistics")
@ResponseBody
private ResponseEntity<?> getStatistics(@RequestParam("key") String mapKey, @RequestParam("view") String viewKey) {
    EntryView<?, ?> entry = inst.getMap(mapKey).getEntryView(viewKey);

    StringBuilder sb = new StringBuilder();
    sb.append("{");

    sb.append("\"size_in_memory\" : ");
    sb.append(entry.getCost());
    sb.append(",\"creationTime\" : \"");
    sb.append(entry.getCreationTime());
    sb.append("\"");
    sb.append(",\"expirationTime\" : \"");
    sb.append(entry.getExpirationTime());
    sb.append("\"");
    sb.append(",\"number of hits\" : ");
    sb.append(entry.getHits());
    sb.append(",\"lastAccessedTime\" : \"");
    sb.append(entry.getLastAccessTime());
    sb.append("\"");
    sb.append(",\"lastUpdateTime\" : \"");
    sb.append(entry.getLastUpdateTime());
    sb.append("\"");
    sb.append(",\"version\" : \"");
    sb.append(entry.getVersion());
    sb.append("\"");
    sb.append(",\"key\" : \"");
    sb.append(entry.getKey());
    sb.append("\"");
    sb.append(",\"value\" : \"");
    sb.append(entry.getValue());
    sb.append("\"");

    sb.append("}");
    return ResponseEntity.ok(sb.toString());
}
项目:hazelcast-hibernate    文件:IMapRegionCache.java   
public long getSizeInMemory() {
    long size = 0;
    for (final Object key : map.keySet()) {
        final EntryView entry = map.getEntryView(key);
        if (entry != null) {
            size += entry.getCost();
        }
    }
    return size;
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingUptodate() {
    CacheEntry existing = cacheEntryWithVersion(versionOld);
    CacheEntry merging = cacheEntryWithVersion(versionNew);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(merging, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingStale() {
    CacheEntry existing = cacheEntryWithVersion(versionNew);
    CacheEntry merging = cacheEntryWithVersion(versionOld);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(existing, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingNull() {
    CacheEntry existing = null;
    CacheEntry merging = cacheEntryWithVersion(versionNew);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(merging, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
private EntryView entryWithGivenValue(Object value) {
    EntryView entryView = mock(EntryView.class);
    try {
        when(entryView.getValue()).thenReturn(value);
        return entryView;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

}
项目:hazelcast-hibernate    文件:IMapRegionCache.java   
@Override
public long getSizeInMemory() {
    long size = 0;
    for (final Object key : map.keySet()) {
        final EntryView entry = map.getEntryView(key);
        if (entry != null) {
            size += entry.getCost();
        }
    }
    return size;
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingUptodate() {
    CacheEntry existing = cacheEntryWithVersion(versionOld);
    CacheEntry merging = cacheEntryWithVersion(versionNew);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(merging, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingStale() {
    CacheEntry existing = cacheEntryWithVersion(versionNew);
    CacheEntry merging = cacheEntryWithVersion(versionOld);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(existing, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
@Test
public void merge_mergingNull() {
    CacheEntry existing = null;
    CacheEntry merging = cacheEntryWithVersion(versionNew);

    EntryView entryExisting = entryWithGivenValue(existing);
    EntryView entryMerging = entryWithGivenValue(merging);

    assertEquals(merging, policy.merge("map", entryMerging, entryExisting));
}
项目:hazelcast-hibernate    文件:VersionAwareMapMergePolicyTest.java   
private EntryView entryWithGivenValue(Object value) {
    EntryView entryView = mock(EntryView.class);
    try {
        when(entryView.getValue()).thenReturn(value);
        return entryView;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

}
项目:hazelcast-jet    文件:JobRepository.java   
/**
 * Cleans up stale job records, execution ids and job resources.
 */
void cleanup(Set<Long> runningJobIds) {
    // clean up completed jobRecords
    Set<Long> completedJobIds = jobResults.keySet();
    completedJobIds.forEach(this::deleteJob);

    Set<Long> validJobIds = new HashSet<>();
    validJobIds.addAll(completedJobIds);
    validJobIds.addAll(runningJobIds);
    validJobIds.addAll(jobRecords.keySet());

    // Job ids are never cleaned up.
    // We also don't clean up job records here because they might be started in parallel while cleanup is running
    // If a job id is not running or is completed it might be suitable to clean up job resources
    randomIds.keySet(new FilterJobIdPredicate())
             .stream()
             .filter(jobId -> !validJobIds.contains(jobId))
             .forEach(jobId -> {
                 IMap<String, Object> resources = getJobResources(jobId);
                 if (resources.isEmpty()) {
                     return;
                 }

                 EntryView<String, Object> marker = resources.getEntryView(RESOURCE_MARKER);
                 // If the marker is absent, then job resources may be still uploaded.
                 // Just put the marker so that the job resources may be cleaned up eventually.
                 // If the job resources are still being uploaded, then the marker will be overwritten, which is ok.
                 if (marker == null) {
                     resources.putIfAbsent(RESOURCE_MARKER, RESOURCE_MARKER);
                 } else if (isJobRecordExpired(marker.getCreationTime())) {
                     cleanupJobResourcesAndSnapshots(jobId, resources);
                 }
             });
}
项目:hazelcast-jet    文件:MapDecorator.java   
@Override
public EntryView<K, V> getEntryView(K key) {
    return map.getEntryView(key);
}
项目:bagri    文件:TransactionManagementImpl.java   
public boolean isTxVisible(long txId) throws BagriException {
    if (txId <= TX_INIT) {
        return true;
    }

    long cTx = getCurrentTxId();
    if (txId == cTx) {
        // current tx;
        return true;
    }

    Transaction xTx;
    TransactionIsolation txIsolation;
    if (cTx != TX_NO) {
        // can not be null!
        xTx = txCache.get(cTx);
        if (xTx == null) {
            throw new BagriException("Can not find current Transaction with txId " + cTx + "; txId: " + txId, ecTransNotFound);
        }

        // current tx is already finished!
        if (xTx.getTxState() != TransactionState.started) {
            throw new BagriException("Current Transaction is already " + xTx.getTxState(), ecTransWrongState);
        }

        txIsolation = xTx.getTxIsolation(); 
        if (txIsolation == TransactionIsolation.dirtyRead) {
            // current tx is dirtyRead, can see not-committed tx results
            return true;
        }
    } else {
        // default isolation level
        txIsolation = TransactionIsolation.readCommited;
    }

    //xTx = txCache.get(txId);
    //boolean commited = xTx == null || xTx.getTxState() == TransactionState.commited;
    EntryView<Long, Transaction> eTx = txCache.getEntryView(txId);
    boolean commited = eTx == null || eTx.getValue() == null || 
            eTx.getValue().getTxState() == TransactionState.commited;
    if (txIsolation == TransactionIsolation.readCommited) {
        return commited;
    }

    // txIsolation is repeatableRead or serializable
    if (txId > cTx) {
        // the tx started after current, so it is not visible
        // for current tx
        return false;
    }
    return commited; 
}
项目:hazel-local-cache    文件:LocalCacheProxy.java   
@Override
public EntryView getEntryView(Object key) {
    return null;
}
项目:ravikumaran201504    文件:SMap.java   
/**
 * {@inheritDoc}
 *
 * @deprecated not implemented yet
 * @throws UnsupportedOperationException not implemented yet
 */
@Deprecated
@Override
public EntryView<K, V> getEntryView(K key) {
    throw new UnsupportedOperationException();
}