本文整理汇总了Java中org.apache.cassandra.config.Config.setClientMode方法的典型用法代码示例。如果您正苦于以下问题:Java Config.setClientMode方法的具体用法?Java Config.setClientMode怎么用?Java Config.setClientMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.config.Config
的用法示例。
在下文中一共展示了Config.setClientMode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
Config.setClientMode(true);
// Print usage if no argument is specified.
if (args.length < 2 || args.length > 3)
{
System.err.println("Usage: " + Client.class.getSimpleName() + " <host> <port> [<version>]");
return;
}
// Parse options.
String host = args[0];
int port = Integer.parseInt(args[1]);
int version = args.length == 3 ? Integer.parseInt(args[2]) : Server.CURRENT_VERSION;
ClientEncryptionOptions encryptionOptions = new ClientEncryptionOptions();
System.out.println("CQL binary protocol console " + host + "@" + port + " using native protocol version " + version);
new Client(host, port, version, encryptionOptions).run();
System.exit(0);
}
示例2: metadataFromSSTable
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
@Override
protected CFMetaData metadataFromSSTable(Descriptor desc) throws IOException {
if (!legacy && desc.version.storeRows()) {
return super.metadataFromSSTable(desc);
}
Config.setClientMode(false);
Util.initDatabaseDescriptor();
// load keyspace descriptions.
Schema.instance.loadFromDiskForTool();
CFMetaData metaData = Schema.instance.getCFMetaData(desc);
if (metaData == null) {
throw new IllegalArgumentException(String.format(
"Could not locate schema info for %s/(%s:%s). "
+ "Make sure your 'data_file_directories' is pointed correctly.",
desc, desc.ksname, desc.cfname));
}
return metaData;
}
示例3: main
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
public static void main(String args[]) {
Config.setClientMode(true);
LoaderOptions options = LoaderOptions.parseArgs(args);
try {
File dir = options.directory;
if (dir.isFile()) {
dir = dir.getParentFile();
}
String keyspace = dir.getParentFile().getName();
CQLClient client = new CQLClient(options, keyspace);
SSTableToCQL ssTableToCQL = new SSTableToCQL(keyspace, client);
try {
ssTableToCQL.stream(options.directory);
} finally {
client.close();
}
System.exit(0);
} catch (Throwable t) {
t.printStackTrace();
System.exit(1);
}
}
示例4: AbstractBulkRecordWriter
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
protected AbstractBulkRecordWriter(Configuration conf)
{
Config.setClientMode(true);
Config.setOutboundBindAny(true);
this.conf = conf;
DatabaseDescriptor.setStreamThroughputOutboundMegabitsPerSec(Integer.parseInt(conf.get(STREAM_THROTTLE_MBITS, "0")));
maxFailures = Integer.parseInt(conf.get(MAX_FAILED_HOSTS, "0"));
bufferSize = Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64"));
}
示例5: BulkRecordWriter
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
BulkRecordWriter(Configuration conf)
{
Config.setClientMode(true);
Config.setOutboundBindAny(true);
this.conf = conf;
DatabaseDescriptor.setStreamThroughputOutboundMegabitsPerSec(Integer.parseInt(conf.get(STREAM_THROTTLE_MBITS, "0")));
maxFailures = Integer.parseInt(conf.get(MAX_FAILED_HOSTS, "0"));
}
示例6: BulkRecordWriter
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
BulkRecordWriter(Configuration conf) {
Config.setClientMode(true);
Config.setOutboundBindAny(true);
this.conf = conf;
DatabaseDescriptor.setStreamThroughputOutboundMegabitsPerSec(Integer.parseInt(conf.get(STREAM_THROTTLE_MBITS, "0")));
maxFailures = Integer.parseInt(conf.get(MAX_FAILED_HOSTS, "0"));
}
示例7: CrunchBulkRecordWriter
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
public CrunchBulkRecordWriter(TaskAttemptContext context) {
Config.setClientMode(true);
Config.setOutboundBindAny(true);
this.conf = HadoopCompat.getConfiguration(context);
this.context = context;
int megabitsPerSec = Integer.parseInt(conf.get(STREAM_THROTTLE_MBITS, "0"));
LOG.info("Setting stream throttling to " + megabitsPerSec);
DatabaseDescriptor.setStreamThroughputOutboundMegabitsPerSec(megabitsPerSec);
DatabaseDescriptor.setInterDCStreamThroughputOutboundMegabitsPerSec(megabitsPerSec);
heartbeat = new ProgressHeartbeat(context, 120);
}
示例8: validateThriftAccessible
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
public void validateThriftAccessible(final Optional<Integer> rpcPort) {
Config.setClientMode(true);
int port = rpcPort.or(ConfigHelper.getOutputRpcPort(new Configuration()));
ExternalSSTableLoaderClient client = new ExternalSSTableLoaderClient(this.host, port, null, null);
client.init(this.keyspace);
if (client.getCFMetaData(this.keyspace, this.columnFamily) == null) {
throw new CrunchRuntimeException("Column family not accessible: " + this.keyspace + "." + this.columnFamily);
}
}
示例9: tearDown
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
@AfterClass
public static void tearDown()
{
Config.setClientMode(false);
}
示例10: cleanup
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
@AfterClass
public static void cleanup() throws Exception
{
Config.setClientMode(false);
}
示例11: main
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
/**
* @param args a list of sstables whose metadata we are changing
*/
public static void main(final String[] args) throws IOException
{
// Necessary since BufferPool used in RandomAccessReader needs to access DatabaseDescriptor
Config.setClientMode(true);
PrintStream out = System.out;
if (args.length == 0)
{
out.println("This command should be run with Cassandra stopped!");
out.println("Usage: sstablerepairedset [--is-repaired | --is-unrepaired] [-f <sstable-list> | <sstables>]");
System.exit(1);
}
if (args.length < 3 || !args[0].equals("--really-set") || (!args[1].equals("--is-repaired") && !args[1].equals("--is-unrepaired")))
{
out.println("This command should be run with Cassandra stopped, otherwise you will get very strange behavior");
out.println("Verify that Cassandra is not running and then execute the command like this:");
out.println("Usage: sstablerepairedset --really-set [--is-repaired | --is-unrepaired] [-f <sstable-list> | <sstables>]");
System.exit(1);
}
Util.initDatabaseDescriptor();
boolean setIsRepaired = args[1].equals("--is-repaired");
List<String> fileNames;
if (args[2].equals("-f"))
{
fileNames = Files.readAllLines(Paths.get(args[3]), Charset.defaultCharset());
}
else
{
fileNames = Arrays.asList(args).subList(2, args.length);
}
for (String fname: fileNames)
{
Descriptor descriptor = Descriptor.fromFilename(fname);
if (descriptor.version.hasRepairedAt())
{
if (setIsRepaired)
{
FileTime f = Files.getLastModifiedTime(new File(descriptor.filenameFor(Component.DATA)).toPath());
descriptor.getMetadataSerializer().mutateRepairedAt(descriptor, f.toMillis());
}
else
{
descriptor.getMetadataSerializer().mutateRepairedAt(descriptor, ActiveRepairService.UNREPAIRED_SSTABLE);
}
}
else
{
System.err.println("SSTable " + fname + " does not have repaired property, run upgradesstables");
}
}
}
示例12: tearDown
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
@AfterClass
public static void tearDown() throws Exception
{
Config.setClientMode(false);
}
示例13: setUp
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
@Before
public void setUp()
{
this.testDirectory = Files.createTempDir();
Config.setClientMode(true);
}
示例14: main
import org.apache.cassandra.config.Config; //导入方法依赖的package包/类
/**
* Counts the number of tombstones, per row, in a given SSTable
*
* Assumes RandomPartitioner, standard columns and UTF8 encoded row keys
*
* Does not require a cassandra.yaml file or system tables.
*
* @param args command lines arguments
*
* @throws java.io.IOException on failure to open/read/write files or output streams
*/
public static void main(String[] args) throws IOException, ParseException {
String usage = String.format("Usage: %s [-l] <sstable> [<sstable> ...]%n", CountTombstones.class.getName());
final Options options = new Options();
options.addOption("l", "legend", false, "Include column name explanation");
options.addOption("p", "partitioner", true, "The partitioner used by database");
CommandLineParser parser = new BasicParser();
CommandLine cmd = parser.parse(options, args);
if (cmd.getArgs().length < 1)
{
System.err.println("You must supply at least one sstable");
System.err.println(usage);
System.exit(1);
}
// Fake DatabaseDescriptor settings so we don't have to load cassandra.yaml etc
Config.setClientMode(true);
String partitionerName = String.format("org.apache.cassandra.dht.%s",
cmd.hasOption("p") ? cmd.getOptionValue("p") : "RandomPartitioner");
try {
Class<?> clazz = Class.forName(partitionerName);
IPartitioner partitioner = (IPartitioner) clazz.newInstance();
DatabaseDescriptor.setPartitioner(partitioner);
} catch (Exception e) {
throw new RuntimeException("Can't instantiate partitioner " + partitionerName);
}
PrintStream out = System.out;
for (String arg : cmd.getArgs()) {
String ssTableFileName = new File(arg).getAbsolutePath();
Descriptor descriptor = Descriptor.fromFilename(ssTableFileName);
run(descriptor, cmd, out);
}
System.exit(0);
}