本文整理汇总了Java中com.ociweb.pronghorn.pipe.PipeReader.tryMoveSingleMessage方法的典型用法代码示例。如果您正苦于以下问题:Java PipeReader.tryMoveSingleMessage方法的具体用法?Java PipeReader.tryMoveSingleMessage怎么用?Java PipeReader.tryMoveSingleMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ociweb.pronghorn.pipe.PipeReader
的用法示例。
在下文中一共展示了PipeReader.tryMoveSingleMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
if (moveInProgress) {
if (!PipeReader.tryMoveSingleMessage(input, output)) {
return;
} else {
moveInProgress = false;
PipeReader.releaseReadLock(input);
}
}
while (PipeWriter.hasRoomForWrite(output) && PipeReader.tryReadFragment(input)) {
count++;
int value = PipeReader.readInt(input, varFieldLoc);
if (0 != (mask&value)) {
if (!PipeReader.tryMoveSingleMessage(input, output)) {
moveInProgress = true;
return;
}
}
PipeReader.releaseReadLock(input);
}
}
示例2: run
import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
if (moveInProgress) {
if (!PipeReader.tryMoveSingleMessage(input, output)) {
return;
} else {
moveInProgress = false;
PipeReader.releaseReadLock(input);
}
}
boolean updateFile = false;
while (PipeWriter.hasRoomForWrite(output) && PipeReader.tryReadFragment(input)) {
updateFile = true;
byte[] backing = PipeReader.readBytesBackingArray(input, varFieldLoc);
int pos = PipeReader.readBytesPosition(input, varFieldLoc);
int len = PipeReader.readBytesLength(input, varFieldLoc);
int mask = PipeReader.readBytesMask(input, varFieldLoc);
if (!filter.mayContain(backing,pos,len,mask)) {
filter.addValue(backing,pos,len,mask);
if (! PipeReader.tryMoveSingleMessage(input, output)) {
moveInProgress = true;
return;
}
}
PipeReader.releaseReadLock(input);
}
if (updateFile) {
saveFilter();
}
}
示例3: run
import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
if (moveInProgress) {
if (!PipeReader.tryMoveSingleMessage(input, output)) {
return;
} else {
moveInProgress = false;
PipeReader.releaseReadLock(input);
}
}
boolean updateFile = false;
while (PipeWriter.hasRoomForWrite(output) && PipeReader.tryReadFragment(input)) {
updateFile = true;
byte[] backing = PipeReader.readBytesBackingArray(input, varFieldLoc);
int pos = PipeReader.readBytesPosition(input, varFieldLoc);
int len = PipeReader.readBytesLength(input, varFieldLoc);
int mask = PipeReader.readBytesMask(input, varFieldLoc);
int i = instances;
while (--i>=0 && filters[i].mayContain(backing,pos,len,mask)) {
}
if (i<0) {
if (!PipeReader.tryMoveSingleMessage(input, output)) {
moveInProgress = true;
return;
}
} else {
//this one did not contain it so add it.
filters[i].addValue(backing,pos,len,mask);
}
PipeReader.releaseReadLock(input);
}
if (updateFile) {
saveFilter();
}
}
示例4: run
import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
do {
if (-2==this.msgId) {
if (PipeReader.tryReadFragment(this.inputRing)) {
//shutdown logic
if ((this.msgId = PipeReader.getMsgIdx(this.inputRing))<0) {
PipeReader.releaseReadLock(this.inputRing);
this.requestShutdown();
return;
}
} else {
//nothing to read so try again
return;
}
}
//continue trying to move this message until we reach the end
if (PipeReader.tryMoveSingleMessage(this.inputRing, this.outputRings[this.targetRing])) {
//we have reached the end of the message
PipeReader.releaseReadLock(this.inputRing);
if (--this.targetRing<0) {
this.targetRing = this.targetRingInit;
}
this.msgId = -2;
} else {
return;
}
} while(true);
}
示例5: run
import com.ociweb.pronghorn.pipe.PipeReader; //导入方法依赖的package包/类
@Override
public void run() {
int[] slab = Pipe.slab(input);
byte[] blob = Pipe.blob(input);
int slabMask = Pipe.slabMask(input);
int blobMask = Pipe.blobMask(input);
do {
if (-2==this.msgId) {
if (PipeReader.tryReadFragment(this.input)) {
//Shutdown logic
if ((this.msgId = PipeReader.getMsgIdx(this.input))<0) {
PipeReader.releaseReadLock(this.input);
this.requestShutdown();
return;
} else {
//////////////////
//NOTE: This bloom filer will only use the content of the first fragment
// as the input to the hash
//////////////////
int slabLength = Pipe.sizeOf(this.input, this.msgId);
long endOfFragment = Pipe.getWorkingTailPosition(input);
int slabPos = (int)(slabMask & (endOfFragment-slabLength));
int blobLength = slab[(int)(slabMask & (endOfFragment-1))];
int blobPos = Pipe.bytesReadBase(input);
this.targetPipe = outputs[bloomFilter.add(slab,slabPos,slabMask,slabLength,blob,blobPos,blobMask,blobLength)];
}
} else {
//unable to read anything try again later
return;
}
}
if (PipeReader.tryMoveSingleMessage(this.input, this.targetPipe)) {
PipeReader.releaseReadLock(this.input);
this.msgId = -2;
} else {
return;
}
} while(true);
}