本文整理汇总了Java中backtype.storm.utils.TimeCacheMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TimeCacheMap.put方法的具体用法?Java TimeCacheMap.put怎么用?Java TimeCacheMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.utils.TimeCacheMap
的用法示例。
在下文中一共展示了TimeCacheMap.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadChunk
import backtype.storm.utils.TimeCacheMap; //导入方法依赖的package包/类
/**
* uploading topology jar data
*/
@Override
public void uploadChunk(String location, ByteBuffer chunk) throws TException {
TimeCacheMap<Object, Object> uploaders = data.getUploaders();
Object obj = uploaders.get(location);
if (obj == null) {
throw new TException("File for that location does not exist (or timed out) " + location);
}
try {
if (obj instanceof WritableByteChannel) {
WritableByteChannel channel = (WritableByteChannel) obj;
channel.write(chunk);
uploaders.put(location, channel);
} else {
throw new TException("Object isn't WritableByteChannel for " + location);
}
} catch (IOException e) {
String errMsg = " WritableByteChannel write filed when uploadChunk " + location;
LOG.error(errMsg);
throw new TException(e);
}
}
示例2: uploadChunk
import backtype.storm.utils.TimeCacheMap; //导入方法依赖的package包/类
/**
* uploading topology jar data
*/
@Override
public void uploadChunk(String location, ByteBuffer chunk)
throws TException {
TimeCacheMap<Object, Object> uploaders = data.getUploaders();
Object obj = uploaders.get(location);
if (obj == null) {
throw new TException(
"File for that location does not exist (or timed out) "
+ location);
}
try {
if (obj instanceof WritableByteChannel) {
WritableByteChannel channel = (WritableByteChannel) obj;
channel.write(chunk);
uploaders.put(location, channel);
} else {
throw new TException("Object isn't WritableByteChannel for "
+ location);
}
} catch (IOException e) {
String errMsg = " WritableByteChannel write filed when uploadChunk "
+ location;
LOG.error(errMsg);
throw new TException(e);
}
}
示例3: downloadChunk
import backtype.storm.utils.TimeCacheMap; //导入方法依赖的package包/类
@Override
public ByteBuffer downloadChunk(String id) throws TException {
TimeCacheMap<Object, Object> downloaders = data.getDownloaders();
Object obj = downloaders.get(id);
if (obj == null) {
throw new TException("Could not find input stream for that id");
}
try {
if (obj instanceof BufferFileInputStream) {
BufferFileInputStream is = (BufferFileInputStream) obj;
byte[] ret = is.read();
if (ret != null) {
downloaders.put(id, is);
return ByteBuffer.wrap(ret);
}
} else {
throw new TException("Object isn't BufferFileInputStream for "
+ id);
}
} catch (IOException e) {
LOG.error("BufferFileInputStream read failed when downloadChunk ",
e);
throw new TException(e);
}
byte[] empty = {};
return ByteBuffer.wrap(empty);
}
示例4: downloadChunk
import backtype.storm.utils.TimeCacheMap; //导入方法依赖的package包/类
@Override
public ByteBuffer downloadChunk(String id) throws TException {
TimeCacheMap<Object, Object> downloaders = data.getDownloaders();
Object obj = downloaders.get(id);
if (obj == null) {
throw new TException("Could not find input stream for that id");
}
try {
if (obj instanceof BufferFileInputStream) {
BufferFileInputStream is = (BufferFileInputStream) obj;
byte[] ret = is.read();
if (ret != null) {
downloaders.put(id, (BufferFileInputStream) is);
return ByteBuffer.wrap(ret);
}
} else {
throw new TException("Object isn't BufferFileInputStream for "
+ id);
}
} catch (IOException e) {
LOG.error("BufferFileInputStream read failed when downloadChunk ",
e);
throw new TException(e);
}
byte[] empty = {};
return ByteBuffer.wrap(empty);
}
示例5: downloadChunk
import backtype.storm.utils.TimeCacheMap; //导入方法依赖的package包/类
@Override
public ByteBuffer downloadChunk(String id) throws TException {
TimeCacheMap<Object, Object> downloaders = data.getDownloaders();
Object obj = downloaders.get(id);
if (obj == null) {
throw new TException("Could not find input stream for that id");
}
try {
if (obj instanceof BufferFileInputStream) {
BufferFileInputStream is = (BufferFileInputStream) obj;
byte[] ret = is.read();
if (ret != null) {
downloaders.put(id, is);
return ByteBuffer.wrap(ret);
}
} else {
throw new TException("Object isn't BufferFileInputStream for " + id);
}
} catch (IOException e) {
LOG.error("BufferFileInputStream read failed when downloadChunk ", e);
throw new TException(e);
}
byte[] empty = {};
return ByteBuffer.wrap(empty);
}