use of org.apache.ignite.internal.util.typedef.T2 in project ignite by apache.
the class IgniteCachePeekModesAbstractTest method offheapKeys.
/**
* @param nodeIdx Node index.
* @return Tuple with primary and backup keys.
*/
private T2<List<Integer>, List<Integer>> offheapKeys(int nodeIdx) {
GridCacheAdapter<Integer, String> internalCache = ((IgniteKernal) ignite(nodeIdx)).context().cache().internalCache(DEFAULT_CACHE_NAME);
// TODO GG-11148.
Iterator<Map.Entry<Integer, String>> offheapIt = Collections.EMPTY_MAP.entrySet().iterator();
// if (internalCache.context().isNear())
// offheapIt = internalCache.context().near().dht().context().swap().lazyOffHeapIterator(false);
// else
// offheapIt = internalCache.context().swap().lazyOffHeapIterator(false);
Affinity aff = ignite(nodeIdx).affinity(DEFAULT_CACHE_NAME);
ClusterNode node = ignite(nodeIdx).cluster().localNode();
List<Integer> primary = new ArrayList<>();
List<Integer> backups = new ArrayList<>();
while (offheapIt.hasNext()) {
Map.Entry<Integer, String> e = offheapIt.next();
if (aff.isPrimary(node, e.getKey()))
primary.add(e.getKey());
else {
assertTrue(aff.isBackup(node, e.getKey()));
backups.add(e.getKey());
}
}
return new T2<>(primary, backups);
}
use of org.apache.ignite.internal.util.typedef.T2 in project ignite by apache.
the class GridCacheNearMultiNodeSelfTest method testMappings.
/** Test mappings. */
public void testMappings() {
mapDebug = false;
int cnt = 100000;
Map<UUID, T2<Set<Integer>, Set<Integer>>> map = mapKeys(cnt);
for (ClusterNode n : grid(0).cluster().nodes()) {
Set<Integer> primary = map.get(n.id()).get1();
Set<Integer> backups = map.get(n.id()).get2();
if (backups == null)
backups = Collections.emptySet();
info("Grid node [primaries=" + primary.size() + ", backups=" + backups.size() + ']');
assert !F.isEmpty(primary);
assertEquals(backups.size(), cnt - primary.size());
}
}
use of org.apache.ignite.internal.util.typedef.T2 in project ignite by apache.
the class IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest method checkRegisteredIpcEndpoints.
/**
* Counts all registered IPC endpoints.
*
* @return Tuple2 where (tcp endpoints count, shmem endpoints count).
* @throws Exception If failed.
*/
protected T2<Integer, Integer> checkRegisteredIpcEndpoints() throws Exception {
GridKernalContext ctx = ((IgniteKernal) grid()).context();
int tcp = 0;
int shmem = 0;
for (GridPortRecord record : ctx.ports().records()) {
if (record.clazz() == IpcSharedMemoryServerEndpoint.class)
shmem++;
else if (record.clazz() == IpcServerTcpEndpoint.class)
tcp++;
}
return new T2<>(tcp, shmem);
}
use of org.apache.ignite.internal.util.typedef.T2 in project ignite by apache.
the class WebSessionFilter method doFilterV1.
/**
* @param httpReq Request.
* @param res Response.
* @param chain Filter chain.
* @return Session ID.
* @throws IOException In case of I/O error.
* @throws ServletException In case of servlet error.
* @throws CacheException In case of other error.
*/
private String doFilterV1(HttpServletRequest httpReq, ServletResponse res, FilterChain chain) throws IOException, ServletException, CacheException {
WebSession cached = null;
String sesId = httpReq.getRequestedSessionId();
if (sesId != null) {
sesId = transformSessionId(sesId);
for (int i = 0; i < retries; i++) {
try {
cached = cache.get(sesId);
break;
} catch (CacheException | IgniteException | IllegalStateException e) {
handleLoadSessionException(sesId, i, e);
}
}
if (cached != null) {
if (log.isDebugEnabled())
log.debug("Using cached session for ID: " + sesId);
if (cached.isNew())
cached = new WebSession(cached.getId(), cached, false);
} else {
if (log.isDebugEnabled())
log.debug("Cached session was invalidated and doesn't exist: " + sesId);
HttpSession ses = httpReq.getSession(false);
if (ses != null) {
try {
ses.invalidate();
} catch (IllegalStateException ignore) {
// Session was already invalidated.
}
}
cached = createSession(httpReq);
}
} else
cached = createSession(httpReq);
assert cached != null;
sesId = cached.getId();
cached.servletContext(ctx);
cached.filter(this);
cached.resetUpdates();
cached.genSes(httpReq.getSession(false));
httpReq = new RequestWrapper(httpReq, cached);
chain.doFilter(httpReq, res);
HttpSession ses = httpReq.getSession(false);
if (ses != null && ses instanceof WebSession) {
Collection<T2<String, Object>> updates = ((WebSession) ses).updates();
if (updates != null)
updateAttributes(transformSessionId(sesId), updates, ses.getMaxInactiveInterval());
}
return sesId;
}
Aggregations