本文整理了Java中org.apache.ignite.Ignite.queue()
方法的一些代码示例,展示了Ignite.queue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignite.queue()
方法的具体详情如下:
包路径:org.apache.ignite.Ignite
类名称:Ignite
方法名:queue
[英]Will get a named queue from cache and create one if it has not been created yet and cfg is not null. If queue is present already, queue properties will not be changed. Use collocation for CacheMode#PARTITIONED caches if you have lots of relatively small queues as it will make fetching, querying, and iteration a lot faster. If you have few very large queues, then you should consider turning off collocation as they simply may not fit in a single node's memory.
[中]将从缓存中获取命名队列,并在尚未创建且cfg不为null时创建一个。如果队列已存在,则不会更改队列属性。如果您有许多相对较小的队列,请使用CacheMode#分区缓存的配置,因为这将使获取、查询和迭代速度大大加快。如果您的队列非常少,那么您应该考虑关闭配置,因为它们可能不适合于单个节点的内存。
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.queue(name, 0, null);
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Nullable @Override public <T> IgniteQueue<T> queue(String name,
int cap,
CollectionConfiguration cfg)
{
checkIgnite();
return g.queue(name, cap, cfg);
}
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.queue(name, 0, null);
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public void init(ServiceContext ctx) {
Ignite ignite = Ignition.localIgnite();
reqQueue = ignite.queue(String.format(INFERENCE_REQUEST_QUEUE_NAME_PATTERN, suffix), QUEUE_CAPACITY,
queueCfg);
resQueue = ignite.queue(String.format(INFERENCE_RESPONSE_QUEUE_NAME_PATTERN, suffix), QUEUE_CAPACITY,
queueCfg);
mdl = parser.parse(reader.read());
}
代码示例来源:origin: apache/ignite
@Override public Object call() throws Exception {
boolean failed = false;
try {
client.queue("TestQueue", 10, getCollectionConfiguration());
}
catch (IgniteClientDisconnectedException e) {
failed = true;
checkAndWait(e);
}
assertTrue(failed);
return client.queue("TestQueue", 10, getCollectionConfiguration());
}
},
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.queue(name, 0, config(false));
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.queue(name, 0, config(false));
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
@Override public Object apply(Ignite ignite) {
IgniteQueue<Integer> queue = ignite.queue(STRUCTURE_NAME, 0, null);
assertNotNull(queue);
Integer val = queue.peek();
assertNotNull(val);
assert val > 0;
return null;
}
});
代码示例来源:origin: apache/ignite
@Override public void applyx(Ignite ignite) {
IgniteQueue<Integer> q = ignite.queue(TEST_QUEUE_NAME, 0, colCfg);
for (int i = 0; i < operationsPerTx; i++) {
q.put(RAND.nextInt(MAX_INT));
long cnt = writes.incrementAndGet();
if (cnt % WRITE_LOG_MOD == 0)
info("Performed " + cnt + " writes.");
}
}
};
代码示例来源:origin: apache/ignite
@Override public void applyx(Ignite ignite) {
IgniteQueue<Integer> q = ignite.queue(TEST_QUEUE_NAME, 0, colCfg);
for (int i = 0; i < operationsPerTx; i++) {
q.peek();
long cnt = reads.incrementAndGet();
if (cnt % READ_LOG_MOD == 0)
info("Performed " + cnt + " reads.");
}
}
};
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Integer call() throws IgniteCheckedException {
assertNotNull(ignite);
ignite.log().info("Running job [node=" + ignite.cluster().localNode().id() + ", job=" + this + "]");
IgniteQueue<Integer> queue = ignite.queue(queueName, 0, null);
assertNotNull(queue);
Collection<Integer> items = new ArrayList<>();
for (int i = 0; i < size; i++)
items.add(cntr.getAndIncrement());
queue.addAll(items);
return queue.size();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Integer call() throws IgniteCheckedException {
assertNotNull(ignite);
ignite.log().info("Running job [node=" + ignite.cluster().localNode().id() + ", job=" + this + "]");
IgniteQueue<Integer> queue = ignite.queue(queueName, 0, null);
assertNotNull(queue);
for (int i = 0; i < retries; i++)
queue.put(cntr.getAndIncrement());
return queue.size();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Integer call() throws IgniteCheckedException {
assertNotNull(ignite);
ignite.log().info("Running job [node=" + ignite.cluster().localNode().id() + ", job=" + this + "]");
IgniteQueue<String> queue = ignite.queue(queueName, QUEUE_CAPACITY, colCfg);
assertNotNull(queue);
assertEquals(1, queue.size());
for (int i = 0; i < retries; i++) {
assertEquals(expVal, queue.peek());
assertEquals(expVal, queue.element());
}
return queue.size();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Integer call() throws IgniteCheckedException {
assertNotNull(ignite);
ignite.log().info("Running job [node=" + ignite.cluster().localNode().id() + ", job=" + this + ']');
IgniteQueue<Integer> queue = ignite.queue(queueName, 0, null);
assertNotNull(queue);
for (int i = 0; i < retries; i++) {
queue.put(i);
assertNotNull(queue.take());
}
return queue.size();
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Integer call() throws IgniteCheckedException {
assertNotNull(ignite);
ignite.log().info("Running job [node=" + ignite.cluster().localNode().id() + ", job=" + this + "]");
IgniteQueue<Integer> queue = ignite.queue(queueName, QUEUE_CAPACITY, colCfg);
assertNotNull(queue);
for (int i = 0; i < retries; i++)
queue.put(i);
return queue.size();
}
代码示例来源:origin: apache/ignite
/**
* @param colCfg Collection configuration.
* @throws Exception If failed.
*/
private void serverNodeReconnect(CollectionConfiguration colCfg) throws Exception {
final Ignite client = grid(serverCount());
final Ignite srv = ignite(0);
assertNotNull(srv.queue("q", 0, colCfg));
assertNotNull(srv.set("s", colCfg));
reconnectClientNode(client, srv, null);
IgniteQueue<Object> q = client.queue("q", 0, null);
assertNotNull(q);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Boolean call() throws IgniteCheckedException {
assertNotNull(ignite);
ignite.log().info("Running job [node=" + ignite.cluster().localNode().id() + ", job=" + this + "]");
IgniteQueue<Integer> queue = ignite.queue(queueName, 0, null);
assert queue != null;
assert queue.capacity() == QUEUE_CAPACITY;
queue.close();
return true;
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Collection<Integer> call() throws Exception {
Collection<Integer> values = new ArrayList<>();
grid.log().info("Running job [node=" + grid.cluster().localNode().id() + ", job=" + this + "]");
IgniteQueue<Integer> locQueue = grid.queue(queueName, QUEUE_CAPACITY, config(false));
grid.log().info("Queue size " + locQueue.size());
for (Integer element : locQueue)
values.add(element);
return values;
}
}
代码示例来源:origin: apache/ignite
@Override public void apply(Ignite ignite) {
for (int i = 0; i < 100; i++) {
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setBackups(1);
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(i % 2 == 0 ? TRANSACTIONAL : ATOMIC);
IgniteQueue q = ignite.queue("q-" + i, 0, colCfg);
q.close();
}
}
});
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Collection<Integer> call() throws Exception {
Collection<Integer> values = new ArrayList<>();
grid.log().info("Running job [node=" + grid.cluster().localNode().id() + "]");
IgniteQueue<Integer> locQueue = grid.queue(queueName, 0, null);
grid.log().info("Queue size " + locQueue.size());
for (Integer element : locQueue)
values.add(element);
grid.log().info("Returning: " + values);
return values;
}
}
内容来源于网络,如有侵权,请联系作者删除!