use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridCacheIoManager method handleMessage.
/**
* @param nodeId Sender node ID.
* @param cacheMsg Message.
*/
@SuppressWarnings("unchecked")
private void handleMessage(UUID nodeId, GridCacheMessage cacheMsg) {
int msgIdx = cacheMsg.lookupIndex();
IgniteBiInClosure<UUID, GridCacheMessage> c = null;
if (msgIdx >= 0) {
Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = idxClsHandlers;
IgniteBiInClosure[] cacheClsHandlers = idxClsHandlers0.get(cacheMsg.cacheId());
if (cacheClsHandlers != null)
c = cacheClsHandlers[msgIdx];
}
if (c == null)
c = clsHandlers.get(new ListenerKey(cacheMsg.cacheId(), cacheMsg.getClass()));
if (c == null) {
IgniteLogger log = cacheMsg.messageLogger(cctx);
StringBuilder msg0 = new StringBuilder("Received message without registered handler (will ignore) [");
appendMessageInfo(cacheMsg, nodeId, msg0);
msg0.append(", locTopVer=").append(cctx.exchange().readyAffinityVersion()).append(", msgTopVer=").append(cacheMsg.topologyVersion()).append(", cacheDesc=").append(cctx.cache().cacheDescriptor(cacheMsg.cacheId())).append(']');
msg0.append(U.nl()).append("Registered listeners:");
Map<Integer, IgniteBiInClosure[]> idxClsHandlers0 = idxClsHandlers;
for (Map.Entry<Integer, IgniteBiInClosure[]> e : idxClsHandlers0.entrySet()) msg0.append(U.nl()).append(e.getKey()).append("=").append(Arrays.toString(e.getValue()));
if (cctx.kernalContext().isStopping()) {
if (log.isDebugEnabled())
log.debug(msg0.toString());
} else
U.error(log, msg0.toString());
return;
}
onMessage0(nodeId, cacheMsg, c);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridResourceLoggerInjector method resource.
/**
* @param ann Annotation.
* @param target Target.
* @return Logger.
*/
@SuppressWarnings("IfMayBeConditional")
private IgniteLogger resource(LoggerResource ann, Object target) {
Class<?> cls = ann.categoryClass();
String cat = ann.categoryName();
IgniteLogger rsrc = getResource();
if (cls != null && cls != Void.class)
rsrc = rsrc.getLogger(cls);
else if (cat != null && !cat.isEmpty())
rsrc = rsrc.getLogger(cat);
else
rsrc = rsrc.getLogger(target.getClass());
return rsrc;
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class SensitiveInfoTestLoggerProxy method readResolve.
/**
* Reconstructs object on unmarshalling.
*
* @return Reconstructed object.
* @throws ObjectStreamException Thrown in case of unmarshalling error.
*/
protected Object readResolve() throws ObjectStreamException {
try {
IgniteBiTuple<String, Object> t = stash.get();
Object ctgrR = t.get2();
IgniteLogger log = IgnitionEx.localIgnite().log();
return ctgrR != null ? log.getLogger(ctgrR) : log;
} catch (IllegalStateException e) {
throw U.withCause(new InvalidObjectException(e.getMessage()), e);
} finally {
stash.remove();
}
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class GridCachePutAllTask method map.
/**
* {@inheritDoc}
*/
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable final Collection<Integer> data) {
assert !subgrid.isEmpty();
// Give preference to wanted node. Otherwise, take the first one.
ClusterNode targetNode = F.find(subgrid, subgrid.get(0), new IgnitePredicate<ClusterNode>() {
/**
* {@inheritDoc}
*/
@Override
public boolean apply(ClusterNode e) {
return preferredNode.equals(e.id());
}
});
return Collections.singletonMap(new ComputeJobAdapter() {
@LoggerResource
private IgniteLogger log;
@IgniteInstanceResource
private Ignite ignite;
@Override
public Object execute() {
if (DEBUG_DATA)
log.info("Going to put data: " + data);
else
log.info("Going to put data [size=" + data.size() + ']');
IgniteCache<Object, Object> cache = ignite.cache(cacheName);
assert cache != null;
HashMap<Integer, Integer> putMap = U.newLinkedHashMap(TX_BOUND);
Iterator<Integer> it = data.iterator();
int cnt = 0;
final int RETRIES = 5;
while (it.hasNext()) {
Integer val = it.next();
putMap.put(val, val);
if (++cnt == TX_BOUND) {
if (DEBUG_DATA)
log.info("Putting keys to cache: " + putMap.keySet());
else
log.info("Putting keys to cache [size=" + putMap.size() + ']');
for (int i = 0; i < RETRIES; i++) {
try {
cache.putAll(putMap);
break;
} catch (CacheException e) {
if (i < RETRIES - 1)
log.info("Put error, will retry: " + e);
else
throw new IgniteException(e);
}
}
cnt = 0;
putMap = U.newLinkedHashMap(TX_BOUND);
}
}
assert cnt < TX_BOUND;
assert putMap.size() == (data.size() % TX_BOUND) : "putMap.size() = " + putMap.size();
if (DEBUG_DATA)
log.info("Putting keys to cache: " + putMap.keySet());
else
log.info("Putting keys to cache [size=" + putMap.size() + ']');
for (int i = 0; i < RETRIES; i++) {
try {
cache.putAll(putMap);
break;
} catch (CacheException e) {
if (i < RETRIES - 1)
log.info("Put error, will retry: " + e);
else
throw new IgniteException(e);
}
}
if (DEBUG_DATA)
log.info("Finished putting data: " + data);
else
log.info("Finished putting data [size=" + data.size() + ']');
return data;
}
}, targetNode);
}
use of org.apache.ignite.IgniteLogger in project ignite by apache.
the class JdbcBatchUpdateTask method doSingleUpdate.
/**
* Performs update.
*
* @param cache Cache.
* @param sqlText SQL text.
* @param args Parameters.
* @return Update counter.
* @throws SQLException If failed.
*/
private Integer doSingleUpdate(IgniteCache<?, ?> cache, String sqlText, List<Object> args) throws SQLException {
SqlFieldsQuery qry = new SqlFieldsQueryEx(sqlText, false);
qry.setPageSize(fetchSize);
qry.setLocal(locQry);
qry.setCollocated(collocatedQry);
qry.setDistributedJoins(distributedJoins);
qry.setSchema(schemaName);
qry.setArgs(args == null ? null : args.toArray());
QueryCursorImpl<List<?>> qryCursor = (QueryCursorImpl<List<?>>) cache.withKeepBinary().query(qry);
if (qryCursor.isQuery()) {
throw createJdbcSqlException(getError("Query produced result set", qry), IgniteQueryErrorCode.STMT_TYPE_MISMATCH);
}
List<List<?>> rows = qryCursor.getAll();
if (F.isEmpty(rows))
return SUCCESS_NO_INFO;
if (rows.size() != 1)
throw new SQLException(getError("Expected single row for update operation result", qry));
List<?> row = rows.get(0);
if (F.isEmpty(row) || row.size() != 1)
throw new SQLException(getError("Expected row size of 1 for update operation", qry));
Object objRes = row.get(0);
if (!(objRes instanceof Long))
throw new SQLException(getError("Unexpected update result type", qry));
Long longRes = (Long) objRes;
if (longRes > Integer.MAX_VALUE) {
IgniteLogger log = ignite.log();
if (log != null)
log.warning(getError("Query updated row counter (" + longRes + ") exceeds integer range", qry));
return Integer.MAX_VALUE;
}
return longRes.intValue();
}
Aggregations