本文整理汇总了Java中org.apache.cassandra.io.sstable.SSTableLoader类的典型用法代码示例。如果您正苦于以下问题:Java SSTableLoader类的具体用法?Java SSTableLoader怎么用?Java SSTableLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SSTableLoader类属于org.apache.cassandra.io.sstable包,在下文中一共展示了SSTableLoader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
public static void main(String args[])
{
LoaderOptions options = LoaderOptions.parseArgs(args);
OutputHandler handler = new OutputHandler.SystemOutput(options.verbose, options.debug);
SSTableLoader loader = new SSTableLoader(options.directory, new ExternalClient(options.hosts, options.rpcPort, options.user, options.passwd), handler);
DatabaseDescriptor.setStreamThroughputOutboundMegabitsPerSec(options.throttle);
StreamResultFuture future = loader.stream(options.ignores);
future.addEventListener(new ProgressIndicator());
try
{
future.get();
System.exit(0); // We need that to stop non daemonized threads
}
catch (Exception e)
{
System.err.println("Streaming to the following hosts failed:");
System.err.println(loader.getFailedHosts());
System.err.println(e);
if (options.debug)
e.printStackTrace(System.err);
System.exit(1);
}
}
示例2: prepareWriter
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
private void prepareWriter() {
try {
if (writer == null) {
writer = CQLSSTableWriter.builder()
.forTable(schema)
.using(insertStatement)
.withPartitioner(ConfigHelper.getOutputPartitioner(conf))
.inDirectory(outputDir)
.sorted()
.build();
}
if (loader == null) {
CrunchExternalClient externalClient = new CrunchExternalClient(conf);
externalClient.addKnownCfs(keyspace, schema);
this.loader = new SSTableLoader(outputDir, externalClient,
new BulkRecordWriter.NullOutputHandler());
}
} catch (Exception e) {
throw new CrunchRuntimeException(e);
}
}
示例3: prepareWriter
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
private void prepareWriter() throws IOException
{
try
{
if (writer == null)
{
writer = CQLSSTableWriter.builder()
.forTable(schema)
.using(insertStatement)
.withPartitioner(ConfigHelper.getOutputPartitioner(conf))
.inDirectory(outputDir)
.withBufferSizeInMB(Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64")))
.build();
}
if (loader == null)
{
ExternalClient externalClient = new ExternalClient(conf);
externalClient.addKnownCfs(keyspace, schema);
this.loader = new SSTableLoader(outputDir, externalClient, new BulkRecordWriter.NullOutputHandler()) {
@Override
public void onSuccess(StreamState finalState)
{
if (deleteSrc)
FileUtils.deleteRecursive(outputDir);
}
};
}
}
catch (Exception e)
{
throw new IOException(e);
}
}
示例4: prepareWriter
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
private void prepareWriter() throws IOException
{
if (outputdir == null)
{
String keyspace = ConfigHelper.getOutputKeyspace(conf);
//dir must be named by ks/cf for the loader
outputdir = new File(getOutputLocation() + File.separator + keyspace + File.separator + ConfigHelper.getOutputColumnFamily(conf));
outputdir.mkdirs();
}
if (writer == null)
{
AbstractType<?> subcomparator = null;
ExternalClient externalClient = null;
String username = ConfigHelper.getOutputKeyspaceUserName(conf);
String password = ConfigHelper.getOutputKeyspacePassword(conf);
if (cfType == CFType.SUPER)
subcomparator = BytesType.instance;
this.writer = new SSTableSimpleUnsortedWriter(
outputdir,
ConfigHelper.getOutputPartitioner(conf),
ConfigHelper.getOutputKeyspace(conf),
ConfigHelper.getOutputColumnFamily(conf),
BytesType.instance,
subcomparator,
Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64")),
ConfigHelper.getOutputCompressionParamaters(conf));
externalClient = new ExternalClient(ConfigHelper.getOutputInitialAddress(conf),
ConfigHelper.getOutputRpcPort(conf),
username,
password);
this.loader = new SSTableLoader(outputdir, externalClient, new NullOutputHandler());
}
}
示例5: prepareWriter
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
private void prepareWriter() throws IOException
{
try
{
if (writer == null)
{
writer = CQLSSTableWriter.builder()
.forTable(schema)
.using(insertStatement)
.withPartitioner(ConfigHelper.getOutputPartitioner(conf))
.inDirectory(outputDir)
.withBufferSizeInMB(Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64")))
.build();
}
if (loader == null)
{
ExternalClient externalClient = new ExternalClient(conf);
externalClient.addKnownCfs(keyspace, schema);
this.loader = new SSTableLoader(outputDir, externalClient, new BulkRecordWriter.NullOutputHandler());
}
}
catch (Exception e)
{
throw new IOException(e);
}
}
示例6: close
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
private void close() throws IOException
{
if (writer != null)
{
writer.close();
SSTableLoader.LoaderFuture future = loader.stream();
while (true)
{
try
{
future.get(1000, TimeUnit.MILLISECONDS);
break;
}
catch (TimeoutException te)
{
progress.progress();
}
catch (InterruptedException e)
{
throw new IOException(e);
}
}
if (future.hadFailures())
{
if (future.getFailedHosts().size() > maxFailures)
throw new IOException("Too many hosts failed: " + future.getFailedHosts());
else
logger.warn("Some hosts failed: " + future.getFailedHosts());
}
}
}
示例7: prepareWriter
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
private void prepareWriter() throws IOException {
if (outputdir == null) {
String keyspace = org.apache.cassandra.hadoop2.ConfigHelper.getOutputKeyspace(conf);
//dir must be named by ks/cf for the loader
outputdir = new File(getOutputLocation() + File.separator + keyspace + File.separator + org.apache.cassandra.hadoop2.ConfigHelper.getOutputColumnFamily(conf));
outputdir.mkdirs();
}
if (writer == null) {
AbstractType<?> subcomparator = null;
ExternalClient externalClient = null;
String username = org.apache.cassandra.hadoop2.ConfigHelper.getOutputKeyspaceUserName(conf);
String password = org.apache.cassandra.hadoop2.ConfigHelper.getOutputKeyspacePassword(conf);
if (cfType == CFType.SUPER) {
subcomparator = BytesType.instance;
}
this.writer = new SSTableSimpleUnsortedWriter(
outputdir,
org.apache.cassandra.hadoop2.ConfigHelper.getOutputPartitioner(conf),
org.apache.cassandra.hadoop2.ConfigHelper.getOutputKeyspace(conf),
org.apache.cassandra.hadoop2.ConfigHelper.getOutputColumnFamily(conf),
BytesType.instance,
subcomparator,
Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64")),
org.apache.cassandra.hadoop2.ConfigHelper.getOutputCompressionParamaters(conf));
externalClient = new ExternalClient(org.apache.cassandra.hadoop2.ConfigHelper.getOutputInitialAddress(conf),
org.apache.cassandra.hadoop2.ConfigHelper.getOutputRpcPort(conf),
username,
password);
this.loader = new SSTableLoader(outputdir, externalClient, new NullOutputHandler());
}
}
示例8: ExternalClient
import org.apache.cassandra.io.sstable.SSTableLoader; //导入依赖的package包/类
public ExternalClient(SSTableLoader.OutputHandler outputHandler)
{
super();
this.outputHandler = outputHandler;
}