本文整理汇总了Java中backtype.storm.utils.BufferFileInputStream.read方法的典型用法代码示例。如果您正苦于以下问题:Java BufferFileInputStream.read方法的具体用法?Java BufferFileInputStream.read怎么用?Java BufferFileInputStream.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.utils.BufferFileInputStream
的用法示例。
在下文中一共展示了BufferFileInputStream.read方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submitJar
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的package包/类
public static String submitJar(Map conf, String localJar) {
if(localJar==null) {
throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
}
NimbusClient client = NimbusClient.getConfiguredClient(conf);
try {
String uploadLocation = client.getClient().beginFileUpload();
LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
BufferFileInputStream is = new BufferFileInputStream(localJar, THRIFT_CHUNK_SIZE_BYTES);
while(true) {
byte[] toSubmit = is.read();
if(toSubmit.length==0) break;
client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
}
client.getClient().finishFileUpload(uploadLocation);
LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
return uploadLocation;
} catch(Exception e) {
throw new RuntimeException(e);
} finally {
client.close();
}
}
示例2: submitJar
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的package包/类
public static String submitJar(Map conf, String localJar) {
if(localJar==null) {
throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
}
NimbusClient client = NimbusClient.getConfiguredClient(conf);
try {
String uploadLocation = client.getClient().beginFileUpload();
LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
BufferFileInputStream is = new BufferFileInputStream(localJar);
while(true) {
byte[] toSubmit = is.read();
if(toSubmit.length==0) break;
client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
}
client.getClient().finishFileUpload(uploadLocation);
LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
return uploadLocation;
} catch(Exception e) {
throw new RuntimeException(e);
} finally {
client.close();
}
}
示例3: downloadChunk
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的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: submitJar
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的package包/类
public static String submitJar(Map conf, String localJar,
String uploadLocation, NimbusClient client) {
if (localJar == null) {
throw new RuntimeException(
"Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
}
try {
LOG.info("Uploading topology jar " + localJar
+ " to assigned location: " + uploadLocation);
int bufferSize = 512 * 1024;
Object maxBufSizeObject = conf
.get(Config.NIMBUS_THRIFT_MAX_BUFFER_SIZE);
if (maxBufSizeObject != null) {
bufferSize = Utils.getInt(maxBufSizeObject) / 2;
}
BufferFileInputStream is = new BufferFileInputStream(localJar,
bufferSize);
while (true) {
byte[] toSubmit = is.read();
if (toSubmit.length == 0)
break;
client.getClient().uploadChunk(uploadLocation,
ByteBuffer.wrap(toSubmit));
}
client.getClient().finishFileUpload(uploadLocation);
LOG.info("Successfully uploaded topology jar to assigned location: "
+ uploadLocation);
return uploadLocation;
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
}
}
示例5: downloadChunk
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的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);
}
示例6: downloadChunk
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的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);
}
示例7: submitJar
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的package包/类
public static String submitJar(Map conf, String localJar, String uploadLocation, NimbusClient client) {
if (localJar == null) {
throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
}
try {
LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
int bufferSize = 512 * 1024;
Object maxBufSizeObject = conf.get(Config.NIMBUS_THRIFT_MAX_BUFFER_SIZE);
if (maxBufSizeObject != null) {
bufferSize = Utils.getInt(maxBufSizeObject) / 2;
}
BufferFileInputStream is = new BufferFileInputStream(localJar, bufferSize);
while (true) {
byte[] toSubmit = is.read();
if (toSubmit.length == 0)
break;
client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
}
client.getClient().finishFileUpload(uploadLocation);
LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
return uploadLocation;
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
}
}
示例8: submitJar
import backtype.storm.utils.BufferFileInputStream; //导入方法依赖的package包/类
public static String submitJar(Map conf, String localJar, String uploadLocation, NimbusClient client) {
if (localJar == null) {
throw new RuntimeException("Must submit topologies using the 'jstorm' client script so that " +
"StormSubmitter knows which jar to upload.");
}
try {
LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
int bufferSize = 512 * 1024;
Object maxBufSizeObject = conf.get(Config.NIMBUS_THRIFT_MAX_BUFFER_SIZE);
if (maxBufSizeObject != null) {
bufferSize = Utils.getInt(maxBufSizeObject) / 2;
}
BufferFileInputStream is = new BufferFileInputStream(localJar, bufferSize);
while (true) {
byte[] toSubmit = is.read();
if (toSubmit.length == 0)
break;
client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
}
client.getClient().finishFileUpload(uploadLocation);
LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
return uploadLocation;
} catch (Exception e) {
throw new RuntimeException(e);
}
}