当前位置: 首页>>代码示例>>Java>>正文


Java BufferFileInputStream类代码示例

本文整理汇总了Java中backtype.storm.utils.BufferFileInputStream的典型用法代码示例。如果您正苦于以下问题:Java BufferFileInputStream类的具体用法?Java BufferFileInputStream怎么用?Java BufferFileInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BufferFileInputStream类属于backtype.storm.utils包,在下文中一共展示了BufferFileInputStream类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFileHandler

import backtype.storm.utils.BufferFileInputStream; //导入依赖的package包/类
public void createFileHandler() {
    TimeCacheMap.ExpiredCallback<Object, Object> expiredCallback = new TimeCacheMap.ExpiredCallback<Object, Object>() {
        @Override
        public void expire(Object key, Object val) {
            try {
                LOG.info("Close file " + String.valueOf(key));
                if (val != null) {
                    if (val instanceof Channel) {
                        Channel channel = (Channel) val;
                        channel.close();
                    } else if (val instanceof BufferFileInputStream) {
                        BufferFileInputStream is = (BufferFileInputStream) val;
                        is.close();
                    }
                }
            } catch (IOException e) {
                LOG.error(e.getMessage(), e);
            }

        }
    };

    int file_copy_expiration_secs = JStormUtils.parseInt(conf.get(Config.NIMBUS_FILE_COPY_EXPIRATION_SECS), 30);
    uploaders = new TimeCacheMap<Object, Object>(file_copy_expiration_secs, expiredCallback);
    downloaders = new TimeCacheMap<Object, Object>(file_copy_expiration_secs, expiredCallback);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:27,代码来源:NimbusData.java

示例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, 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();
    }
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:24,代码来源:StormSubmitter.java

示例3: 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();
    }
}
 
开发者ID:troyding,项目名称:storm-resa,代码行数:24,代码来源:StormSubmitter.java

示例4: createFileHandler

import backtype.storm.utils.BufferFileInputStream; //导入依赖的package包/类
public void createFileHandler() {
    ExpiredCallback<Object, Object> expiredCallback = new ExpiredCallback<Object, Object>() {
        @Override
        public void expire(Object key, Object val) {
            try {
                LOG.info("Close file " + String.valueOf(key));
                if (val != null) {
                    if (val instanceof Channel) {
                        Channel channel = (Channel) val;
                        channel.close();
                    } else if (val instanceof BufferFileInputStream) {
                        BufferFileInputStream is = (BufferFileInputStream) val;
                        is.close();
                    }
                }
            } catch (IOException e) {
                LOG.error(e.getMessage(), e);
            }

        }
    };
    int file_copy_expiration_secs = JStormUtils.parseInt(conf.get(Config.NIMBUS_FILE_COPY_EXPIRATION_SECS), 30);
    uploaders = new TimeCacheMap<>(file_copy_expiration_secs, expiredCallback);
    downloaders = new TimeCacheMap<>(file_copy_expiration_secs, expiredCallback);
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:26,代码来源:NimbusData.java

示例5: createNimbusData

import backtype.storm.utils.BufferFileInputStream; //导入依赖的package包/类
private NimbusData createNimbusData(Map conf, INimbus inimbus)
		throws Exception {

	TimeCacheMap.ExpiredCallback<Object, Object> expiredCallback = new TimeCacheMap.ExpiredCallback<Object, Object>() {
		@Override
		public void expire(Object key, Object val) {
			try {
				LOG.info("Close file " + String.valueOf(key));
				if (val != null) {
					if (val instanceof Channel) {
						Channel channel = (Channel) val;
						channel.close();
					} else if (val instanceof BufferFileInputStream) {
						BufferFileInputStream is = (BufferFileInputStream) val;
						is.close();
					}
				}
			} catch (IOException e) {
				LOG.error(e.getMessage(), e);
			}

		}
	};

	int file_copy_expiration_secs = JStormUtils.parseInt(
			conf.get(Config.NIMBUS_FILE_COPY_EXPIRATION_SECS), 30);
	TimeCacheMap<Object, Object> uploaders = new TimeCacheMap<Object, Object>(
			file_copy_expiration_secs, expiredCallback);
	TimeCacheMap<Object, Object> downloaders = new TimeCacheMap<Object, Object>(
			file_copy_expiration_secs, expiredCallback);

	// Callback callback=new TimerCallBack();
	// StormTimer timer=Timer.mkTimerTimer(callback);
	NimbusData data = new NimbusData(conf, downloaders, uploaders, inimbus);

	return data;

}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:39,代码来源:NimbusServer.java

示例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);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:30,代码来源:ServiceHandler.java

示例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 {

	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:38,代码来源:StormSubmitter.java

示例8: createNimbusData

import backtype.storm.utils.BufferFileInputStream; //导入依赖的package包/类
/**
 * 1.此处定义一个TimcacheMap缓存失效时候的callback函数,关闭channel和stream
 * 建立上传和下载两个缓存,缓存流
 * 新建一个Nimbus对象
 */
@SuppressWarnings("rawtypes")
private NimbusData createNimbusData(Map conf, INimbus inimbus) throws Exception {

    TimeCacheMap.ExpiredCallback<Object, Object> expiredCallback = new TimeCacheMap.ExpiredCallback<Object, Object>() {
        @Override
        public void expire(Object key, Object val) {
            try {
                LOG.info("Close file " + String.valueOf(key));
                if (val != null) {
                    if (val instanceof Channel) {
                        Channel channel = (Channel) val;
                        channel.close();
                    } else if (val instanceof BufferFileInputStream) {
                        BufferFileInputStream is = (BufferFileInputStream) val;
                        is.close();
                    }
                }
            } catch (IOException e) {
                LOG.error(e.getMessage(), e);
            }

        }
    };

    int file_copy_expiration_secs = JStormUtils.parseInt(conf.get(Config.NIMBUS_FILE_COPY_EXPIRATION_SECS), 30);
    TimeCacheMap<Object, Object> uploaders = new TimeCacheMap<Object, Object>(file_copy_expiration_secs,
            expiredCallback);
    TimeCacheMap<Object, Object> downloaders = new TimeCacheMap<Object, Object>(file_copy_expiration_secs,
            expiredCallback);

    // Callback callback=new TimerCallBack();
    // StormTimer timer=Timer.mkTimerTimer(callback);
    NimbusData data = new NimbusData(conf, downloaders, uploaders, inimbus);

    return data;

}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:43,代码来源:NimbusServer.java

示例9: 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);
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:30,代码来源:ServiceHandler.java

示例10: 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);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:28,代码来源:ServiceHandler.java

示例11: 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 {

    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:31,代码来源:StormSubmitter.java

示例12: createNimbusData

import backtype.storm.utils.BufferFileInputStream; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private NimbusData createNimbusData(Map conf, INimbus inimbus)
		throws Exception {

	TimeCacheMap.ExpiredCallback<Object, Object> expiredCallback = new TimeCacheMap.ExpiredCallback<Object, Object>() {
		@Override
		public void expire(Object key, Object val) {
			try {
				LOG.info("Close file " + String.valueOf(key));
				if (val != null) {
					if (val instanceof Channel) {
						Channel channel = (Channel) val;
						channel.close();
					} else if (val instanceof BufferFileInputStream) {
						BufferFileInputStream is = (BufferFileInputStream) val;
						is.close();
					}
				}
			} catch (IOException e) {
				LOG.error(e.getMessage(), e);
			}

		}
	};

	int file_copy_expiration_secs = JStormUtils.parseInt(
			conf.get(Config.NIMBUS_FILE_COPY_EXPIRATION_SECS), 30);
	TimeCacheMap<Object, Object> uploaders = new TimeCacheMap<Object, Object>(
			file_copy_expiration_secs, expiredCallback);
	TimeCacheMap<Object, Object> downloaders = new TimeCacheMap<Object, Object>(
			file_copy_expiration_secs, expiredCallback);

	// Callback callback=new TimerCallBack();
	// StormTimer timer=Timer.mkTimerTimer(callback);
	NimbusData data = new NimbusData(conf, downloaders, uploaders, inimbus);

	return data;

}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:40,代码来源:NimbusServer.java

示例13: 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);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:29,代码来源:StormSubmitter.java


注:本文中的backtype.storm.utils.BufferFileInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。