use of doitincloud.rdbcache.models.KvPair in project rdbcache by rdbcache.
the class QueueOps method onReceiveTask.
public void onReceiveTask(String task) {
LOGGER.debug("Received Task: " + task);
String[] parts = task.split("::");
if (parts.length < 3) {
LOGGER.error("invalid task format");
return;
}
String action = parts[0];
String hashKey = parts[1];
int index = hashKey.indexOf(":");
if (index < 0) {
LOGGER.error("invalid event format, failed to figure out type and key");
return;
}
String type = hashKey.substring(0, index);
String key = hashKey.substring(index + 1);
String traceId = parts[2];
Context context = new Context(traceId);
if (enableMonitor)
context.enableMonitor(task, "queue", action);
KvPair pair = new KvPair(key, type);
KvPairs pairs = new KvPairs(pair);
AnyKey anyKey = new AnyKey();
if (!AppCtx.getKeyInfoRepo().find(context, pairs, anyKey)) {
String msg = "keyInfo not found";
LOGGER.error(msg);
context.logTraceMessage(msg);
return;
}
KeyInfo keyInfo = anyKey.getKeyInfo();
// ...
String msg = "unknown task action:" + action;
LOGGER.error(msg);
context.logTraceMessage(msg);
context.closeMonitor();
}
use of doitincloud.rdbcache.models.KvPair in project rdbcache by rdbcache.
the class AbsDbaseRepo method insert.
@Override
public boolean insert(final Context context, final KvPairs pairs, final AnyKey anyKey) {
boolean allOk = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
if (!insert(context, pair, keyInfo)) {
allOk = false;
}
}
return allOk;
}
use of doitincloud.rdbcache.models.KvPair in project rdbcache by rdbcache.
the class AbsDbaseRepo method save.
@Override
public boolean save(final Context context, final KvPairs pairs, final AnyKey anyKey) {
boolean allOk = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
if (!save(context, pair, keyInfo)) {
allOk = false;
}
}
return allOk;
}
use of doitincloud.rdbcache.models.KvPair in project rdbcache by rdbcache.
the class AbsDbaseRepo method find.
@Override
public boolean find(final Context context, final KvPairs pairs, final AnyKey anyKey) {
boolean allOk = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
if (!find(context, pair, keyInfo)) {
allOk = false;
}
}
return allOk;
}
use of doitincloud.rdbcache.models.KvPair in project rdbcache by rdbcache.
the class SimpleKeyInfoRepo method find.
@Override
public boolean find(Context context, KvPairs pairs, AnyKey anyKey) {
LOGGER.trace("find pairs(" + pairs.size() + ") anyKey(" + anyKey.size() + ")");
boolean foundAll = true;
for (int i = 0; i < pairs.size(); i++) {
KvPair pair = pairs.get(i);
KeyInfo keyInfo = anyKey.getAny(i);
String key = pair.getId();
Map<String, Object> map = (Map<String, Object>) data.get(key);
if (map == null) {
foundAll = false;
LOGGER.trace("find: Not Found " + key);
continue;
} else {
keyInfo = Utils.toPojo(map, KeyInfo.class);
anyKey.set(i, keyInfo);
LOGGER.trace("find: Found " + key);
}
}
return foundAll;
}
Aggregations