本文整理汇总了Java中com.hazelcast.core.IQueue.offer方法的典型用法代码示例。如果您正苦于以下问题:Java IQueue.offer方法的具体用法?Java IQueue.offer怎么用?Java IQueue.offer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.core.IQueue
的用法示例。
在下文中一共展示了IQueue.offer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterator
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
@Test
public void iterator() {
HazelcastClient hClient = getHazelcastClient();
IQueue<String> queue = hClient.getQueue("iterator");
assertTrue(queue.isEmpty());
int count = 100;
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 0; i < count; i++) {
queue.offer("" + i);
map.put(i, 1);
}
Iterator<String> it = queue.iterator();
while (it.hasNext()) {
String o = it.next();
map.put(Integer.valueOf(o), map.get(Integer.valueOf(o)) - 1);
}
for (int i = 0; i < count; i++) {
assertTrue(map.get(i) == 0);
}
}
示例2: removeAll
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
@Test
public void removeAll() {
HazelcastClient hClient = getHazelcastClient();
IQueue<String> queue = hClient.getQueue("removeAll");
assertTrue(queue.isEmpty());
int count = 100;
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 0; i < count; i++) {
queue.offer("" + i);
map.put(i, 1);
}
List<String> list = new ArrayList<String>();
for (int i = 0; i < count / 2; i++) {
list.add(String.valueOf(i));
}
queue.removeAll(list);
assertTrue(queue.size() == count / 2);
}
示例3: testIterator
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
@Test
public void testIterator() {
HazelcastClient hClient = getHazelcastClient();
IQueue<String> queue = hClient.getQueue("testIterator");
assertTrue(queue.isEmpty());
int count = 100;
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (int i = 0; i < count; i++) {
queue.offer("" + i);
map.put(i, 1);
}
Iterator<String> it = queue.iterator();
while (it.hasNext()) {
String item = it.next();
map.remove(Integer.valueOf(item));
it.remove();
}
assertEquals(0, queue.size());
assertEquals(0, map.size());
}
示例4: testHazelcast
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
@Bean
public Object testHazelcast(HazelcastInstance inst) throws Exception {
ConcurrentMap aMap = inst.getMap("cz.rkr");
aMap.put("initialValue1", "val1");
aMap.put("initialValue2", "val2");
aMap.put("initialValue3", "val3");
aMap.put("initialValue4", "val4");
aMap.put("initialValue5", "val5");
IQueue<String> queueCustomers = inst.getQueue("cz.eetlite");
queueCustomers.offer("Tom");
queueCustomers.offer("Mary");
queueCustomers.offer("Jane");
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("Second customer: " + queueCustomers.peek());
System.out.println("Second customer: " + queueCustomers.peek());
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("Queue size: " + queueCustomers.size());
queueCustomers.put("TEST");
System.out.println("Queue size: " + queueCustomers.size());
System.out.println("take: " + queueCustomers.take());
System.out.println("Queue size: " + queueCustomers.size());
return aMap;
}
示例5: produce
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
private static void produce(HazelcastInstance hazelcastInstance) {
IQueue<String> cola = hazelcastInstance.getQueue("cola");
int count=0;
while (true){
try {
cola.offer(Integer.toString(count++));
Thread.sleep(1000);
System.out.println("Added to queue. It has now "+cola.size());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
示例6: isEmpty
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
@Test
public void isEmpty() {
HazelcastClient hClient = getHazelcastClient();
IQueue<String> queue = hClient.getQueue("isEmpty");
assertTrue(queue.isEmpty());
queue.offer("asd");
assertFalse(queue.isEmpty());
}
示例7: processRow
import com.hazelcast.core.IQueue; //导入方法依赖的package包/类
public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException {
meta = (HazelcastOutputMeta) smi;
data = (HazelcastOutputData) sdi;
Object[] r = getRow(); // get row, set busy!
// If no more input to be expected, stop
if ( r == null ) {
setOutputDone();
return false;
}
if ( first ) {
first = false;
// clone input row meta for now, we will change it (add or set inline) later
data.outputRowMeta = getInputRowMeta().clone();
// Get output field types
meta.getFields( data.outputRowMeta, getStepname(), null, null, this, repository, metaStore );
}
Object[] outputRowData = r;
// Get structure from Hazelcast
String structName = fieldSubstitute( environmentSubstitute( meta.getStructureName() ), getInputRowMeta(), r );
String structType = meta.getStructureType();
// TODO better way to pick which API method to call based on structure type
if ( structType == "Queue" ) {
IQueue<SerializableRow> q = client.getQueue( structName );
SerializableRow sRow = new SerializableRow( data.outputRowMeta, outputRowData );
if ( !q.offer( sRow ) ) {
putError( data.outputRowMeta, outputRowData, 1,
BaseMessages.getString( PKG, "HazelcastOutput.Error.Row.PutRowInQ" ), null, null );
}
}
putRow( data.outputRowMeta, outputRowData ); // copy row to possible alternate rowset(s).
if ( checkFeedback( getLinesRead() ) ) {
if ( log.isBasic() ) {
logBasic( BaseMessages.getString( PKG, "HazelcastOutput.Log.LineNumber" ) + getLinesRead() );
}
}
return true;
}