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


Java DatabaseDescriptor类代码示例

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


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

示例1: main

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的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);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:24,代码来源:BulkLoader.java

示例2: inspectThrowable

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
/**
 * Certain Throwables and Exceptions represent "Die" conditions for the server.
 * This recursively checks the input Throwable's cause hierarchy until null.
 * @param t
 *      The Throwable to check for server-stop conditions
 */
public static void inspectThrowable(Throwable t)
{
    boolean isUnstable = false;
    if (t instanceof OutOfMemoryError)
    {
        isUnstable = true;
        HeapUtils.generateHeapDump();
    }

    if (DatabaseDescriptor.getDiskFailurePolicy() == Config.DiskFailurePolicy.die)
        if (t instanceof FSError || t instanceof CorruptSSTableException)
        isUnstable = true;

    // Check for file handle exhaustion
    if (t instanceof FileNotFoundException || t instanceof SocketException)
        if (t.getMessage().contains("Too many open files"))
            isUnstable = true;

    if (isUnstable)
        killer.killCurrentJVM(t);

    if (t.getCause() != null)
        inspectThrowable(t.getCause());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:31,代码来源:JVMStabilityInspector.java

示例3: before

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
@Override protected void before() throws Throwable {
  if (server != null) return;

  DatabaseDescriptor.daemonInitialization();

  // Cleanup first
  try {
    cleanupAndLeaveDirs();
  } catch (IOException e) {
    throw new RuntimeException("Failed to cleanup and recreate directories.", e);
  }

  Keyspace.setInitialized();
  SystemKeyspace.persistLocalMetadata();
  SystemKeyspace.finishStartup();
  StorageService.instance.initServer();

  server = new Server.Builder().withHost(nativeAddr).withPort(nativePort).build();
  server.start();
}
 
开发者ID:openzipkin,项目名称:brave-cassandra,代码行数:21,代码来源:CassandraRule.java

示例4: deserialize

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
public FileMessageHeader deserialize(DataInputPlus in, int version) throws IOException
{
    UUID cfId = UUIDSerializer.serializer.deserialize(in, MessagingService.current_version);
    int sequenceNumber = in.readInt();
    Version sstableVersion = DatabaseDescriptor.getSSTableFormat().info.getVersion(in.readUTF());

    SSTableFormat.Type format = SSTableFormat.Type.LEGACY;
    if (version >= StreamMessage.VERSION_22)
        format = SSTableFormat.Type.validate(in.readUTF());

    long estimatedKeys = in.readLong();
    int count = in.readInt();
    List<Pair<Long, Long>> sections = new ArrayList<>(count);
    for (int k = 0; k < count; k++)
        sections.add(Pair.create(in.readLong(), in.readLong()));
    CompressionInfo compressionInfo = CompressionInfo.serializer.deserialize(in, MessagingService.current_version);
    long repairedAt = in.readLong();
    int sstableLevel = in.readInt();
    SerializationHeader.Component header = version >= StreamMessage.VERSION_30 && sstableVersion.storeRows()
                                         ? SerializationHeader.serializer.deserialize(sstableVersion, in)
                                         : null;

    return new FileMessageHeader(cfId, sequenceNumber, sstableVersion, format, estimatedKeys, sections, compressionInfo, repairedAt, sstableLevel, header);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:FileMessageHeader.java

示例5: testCommitFailurePolicy_stop

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
@Test
public void testCommitFailurePolicy_stop() throws ConfigurationException
{
    CassandraDaemon daemon = new CassandraDaemon();
    daemon.completeSetup(); //startup must be completed, otherwise commit log failure must kill JVM regardless of failure policy
    StorageService.instance.registerDaemon(daemon);

    // Need storage service active so stop policy can shutdown gossip
    StorageService.instance.initServer();
    Assert.assertTrue(Gossiper.instance.isEnabled());

    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.stop);
        CommitLog.handleCommitError("Test stop error", new Throwable());
        Assert.assertFalse(Gossiper.instance.isEnabled());
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:CommitLogFailurePolicyTest.java

示例6: clearSnapshot

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
/**
 * Remove the snapshot with the given name from the given keyspaces.
 * If no tag is specified we will remove all snapshots.
 */
public void clearSnapshot(String tag, String... keyspaceNames) throws IOException
{
    if(tag == null)
        tag = "";

    Set<String> keyspaces = new HashSet<>();
    for (String dataDir : DatabaseDescriptor.getAllDataFileLocations())
    {
        for(String keyspaceDir : new File(dataDir).list())
        {
            // Only add a ks if it has been specified as a param, assuming params were actually provided.
            if (keyspaceNames.length > 0 && !Arrays.asList(keyspaceNames).contains(keyspaceDir))
                continue;
            keyspaces.add(keyspaceDir);
        }
    }

    for (String keyspace : keyspaces)
        Keyspace.clearSnapshot(tag, keyspace);

    if (logger.isDebugEnabled())
        logger.debug("Cleared out snapshot directories");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:28,代码来源:StorageService.java

示例7: CommitLog

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
private CommitLog()
{
    DatabaseDescriptor.createAllDirectories();

    allocator = new CommitLogSegmentManager();

    executor = DatabaseDescriptor.getCommitLogSync() == Config.CommitLogSync.batch
             ? new BatchCommitLogService(this)
             : new PeriodicCommitLogService(this);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    try
    {
        mbs.registerMBean(this, new ObjectName("org.apache.cassandra.db:type=Commitlog"));
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }

    // register metrics
    metrics = new CommitLogMetrics(executor, allocator);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:CommitLog.java

示例8: initDatabaseDescriptor

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
/**
 * This is used by standalone tools to force static initialization of DatabaseDescriptor, and fail if configuration
 * is bad.
 */
public static void initDatabaseDescriptor()
{
    try
    {
        DatabaseDescriptor.forceStaticInitialization();
    }
    catch (ExceptionInInitializerError e)
    {
        Throwable cause = e.getCause();
        boolean logStackTrace = !(cause instanceof ConfigurationException) || ((ConfigurationException) cause).logStackTrace;
        System.out.println("Exception (" + cause.getClass().getName() + ") encountered during startup: " + cause.getMessage());

        if (logStackTrace)
        {
            cause.printStackTrace();
            System.exit(3);
        }
        else
        {
            System.err.println(cause.getMessage());
            System.exit(3);
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:Util.java

示例9: testFlushUnwriteableDie

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
@Test
public void testFlushUnwriteableDie() throws Throwable
{
    makeTable();

    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
    DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
    try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore()))
    {
        DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.die);
        flushAndExpectError();
        Assert.assertTrue(killerForTests.wasKilled());
        Assert.assertFalse(killerForTests.wasKilledQuietly()); //only killed quietly on startup failure
    }
    finally
    {
        DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:OutOfSpaceTest.java

示例10: send

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
private void send(InetAddress endpoint, Event.NodeEvent event)
{
    if (logger.isTraceEnabled())
        logger.trace("Sending event for endpoint {}, rpc address {}", endpoint, event.nodeAddress());

    // If the endpoint is not the local node, extract the node address
    // and if it is the same as our own RPC broadcast address (which defaults to the rcp address)
    // then don't send the notification. This covers the case of rpc_address set to "localhost",
    // which is not useful to any driver and in fact may cauase serious problems to some drivers,
    // see CASSANDRA-10052
    if (!endpoint.equals(FBUtilities.getBroadcastAddress()) &&
        event.nodeAddress().equals(DatabaseDescriptor.getBroadcastRpcAddress()))
        return;

    send(event);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:Server.java

示例11: bootstrap

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
private void bootstrap(Collection<Token> tokens)
{
    isBootstrapMode = true;
    SystemKeyspace.updateTokens(tokens); // DON'T use setToken, that makes us part of the ring locally which is incorrect until we are done bootstrapping
    if (!DatabaseDescriptor.isReplacing())
    {
        // if not an existing token then bootstrap
        // order is important here, the gossiper can fire in between adding these two states.  It's ok to send TOKENS without STATUS, but *not* vice versa.
        Gossiper.instance.addLocalApplicationState(ApplicationState.TOKENS, valueFactory.tokens(tokens));
        Gossiper.instance.addLocalApplicationState(ApplicationState.STATUS,
                                                   valueFactory.bootstrapping(tokens));
        setMode(Mode.JOINING, "sleeping " + RING_DELAY + " ms for pending range setup", true);
        Uninterruptibles.sleepUninterruptibly(RING_DELAY, TimeUnit.MILLISECONDS);
    }
    else
    {
        // Dont set any state for the node which is bootstrapping the existing token...
        tokenMetadata.updateNormalTokens(tokens, FBUtilities.getBroadcastAddress());
    }
    if (!Gossiper.instance.seenAnySeed())
        throw new IllegalStateException("Unable to contact any seeds!");
    setMode(Mode.JOINING, "Starting to bootstrap...", true);
    new BootStrapper(FBUtilities.getBroadcastAddress(), tokens, tokenMetadata).bootstrap(); // handles token update
    logger.info("Bootstrap completed! for the tokens {}", tokens);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:26,代码来源:StorageService.java

示例12: newSocket

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
public static Socket newSocket(InetAddress endpoint) throws IOException
{
    // zero means 'bind on any available port.'
    if (isEncryptedChannel(endpoint))
    {
        if (Config.getOutboundBindAny())
            return SSLFactory.getSocket(DatabaseDescriptor.getServerEncryptionOptions(), endpoint, DatabaseDescriptor.getSSLStoragePort());
        else
            return SSLFactory.getSocket(DatabaseDescriptor.getServerEncryptionOptions(), endpoint, DatabaseDescriptor.getSSLStoragePort(), FBUtilities.getLocalAddress(), 0);
    }
    else
    {
        Socket socket = SocketChannel.open(new InetSocketAddress(endpoint, DatabaseDescriptor.getStoragePort())).socket();
        if (Config.getOutboundBindAny() && !socket.isBound())
            socket.bind(new InetSocketAddress(FBUtilities.getLocalAddress(), 0));
        return socket;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:OutboundTcpConnectionPool.java

示例13: handleCommitError

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
@VisibleForTesting
public static boolean handleCommitError(String message, Throwable t)
{
    JVMStabilityInspector.inspectCommitLogThrowable(t);
    switch (DatabaseDescriptor.getCommitFailurePolicy())
    {
        // Needed here for unit tests to not fail on default assertion
        case die:
        case stop:
            StorageService.instance.stopTransports();
        case stop_commit:
            logger.error(String.format("%s. Commit disk failure policy is %s; terminating thread", message, DatabaseDescriptor.getCommitFailurePolicy()), t);
            return false;
        case ignore:
            logger.error(message, t);
            return true;
        default:
            throw new AssertionError(DatabaseDescriptor.getCommitFailurePolicy());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:CommitLog.java

示例14: testRegularMode

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
@Test
public void testRegularMode() throws ConfigurationException
{
    SchemaLoader.mkdirs();
    SchemaLoader.cleanup();
    StorageService.instance.initServer(0);
    for (String path : DatabaseDescriptor.getAllDataFileLocations())
    {
        // verify that storage directories are there.
        assertTrue(new File(path).exists());
    }
    // a proper test would be to call decommission here, but decommission() mixes both shutdown and datatransfer
    // calls.  This test is only interested in the shutdown-related items which a properly handled by just
    // stopping the client.
    //StorageService.instance.decommission();
    StorageService.instance.stopClient();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:StorageServiceServerTest.java

示例15: IndexWriter

import org.apache.cassandra.config.DatabaseDescriptor; //导入依赖的package包/类
IndexWriter(long keyCount, final SequentialWriter dataFile)
{
    indexFile = SequentialWriter.open(new File(descriptor.filenameFor(Component.PRIMARY_INDEX)));
    builder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode());
    summary = new IndexSummaryBuilder(keyCount, metadata.getMinIndexInterval(), Downsampling.BASE_SAMPLING_LEVEL);
    bf = FilterFactory.getFilter(keyCount, metadata.getBloomFilterFpChance(), true);
    // register listeners to be alerted when the data files are flushed
    indexFile.setPostFlushListener(new Runnable()
    {
        public void run()
        {
            summary.markIndexSynced(indexFile.getLastFlushOffset());
        }
    });
    dataFile.setPostFlushListener(new Runnable()
    {
        public void run()
        {
            summary.markDataSynced(dataFile.getLastFlushOffset());
        }
    });
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:SSTableWriter.java


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