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


Java SystemKeyspace类代码示例

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


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

示例1: before

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的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

示例2: getDatacenter

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
/**
 * Return the data center for which an endpoint resides in
 *
 * @param endpoint the endpoint to process
 * @return string of data center
 */
public String getDatacenter(InetAddress endpoint)
{
    if (endpoint.equals(FBUtilities.getBroadcastAddress()))
        return myDC;

    EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
    if (epState == null || epState.getApplicationState(ApplicationState.DC) == null)
    {
        if (psnitch == null)
        {
            if (savedEndpoints == null)
                savedEndpoints = SystemKeyspace.loadDcRackInfo();
            if (savedEndpoints.containsKey(endpoint))
                return savedEndpoints.get(endpoint).get("data_center");
            return DEFAULT_DC;
        }
        else
            return psnitch.getDatacenter(endpoint);
    }
    return epState.getApplicationState(ApplicationState.DC).value;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:GossipingPropertyFileSnitch.java

示例3: getRack

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
/**
 * Return the rack for which an endpoint resides in
 *
 * @param endpoint the endpoint to process
 * @return string of rack
 */
public String getRack(InetAddress endpoint)
{
    if (endpoint.equals(FBUtilities.getBroadcastAddress()))
        return myRack;

    EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
    if (epState == null || epState.getApplicationState(ApplicationState.RACK) == null)
    {
        if (psnitch == null)
        {
            if (savedEndpoints == null)
                savedEndpoints = SystemKeyspace.loadDcRackInfo();
            if (savedEndpoints.containsKey(endpoint))
                return savedEndpoints.get(endpoint).get("rack");
            return DEFAULT_RACK;
        }
        else
            return psnitch.getRack(endpoint);
    }
    return epState.getApplicationState(ApplicationState.RACK).value;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:GossipingPropertyFileSnitch.java

示例4: fetchAsync

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
public StreamResultFuture fetchAsync()
{
    for (Map.Entry<String, Map.Entry<InetAddress, Collection<Range<Token>>>> entry : toFetch.entries())
    {
        String keyspace = entry.getKey();
        InetAddress source = entry.getValue().getKey();
        InetAddress preferred = SystemKeyspace.getPreferredIP(source);
        Collection<Range<Token>> ranges = entry.getValue().getValue();
        /* Send messages to respective folks to stream data over to me */
        if (logger.isDebugEnabled())
            logger.debug("{}ing from {} ranges {}", description, source, StringUtils.join(ranges, ", "));
        streamPlan.requestRanges(source, preferred, keyspace, ranges);
    }

    return streamPlan.execute();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:RangeStreamer.java

示例5: bootstrap

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的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
        List<Pair<ApplicationState, VersionedValue>> states = new ArrayList<Pair<ApplicationState, VersionedValue>>();
        states.add(Pair.create(ApplicationState.TOKENS, valueFactory.tokens(tokens)));
        states.add(Pair.create(ApplicationState.STATUS, valueFactory.bootstrapping(tokens)));
        Gossiper.instance.addLocalApplicationStates(states);
        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());
        SystemKeyspace.removeEndpoint(DatabaseDescriptor.getReplaceAddress());
    }
    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:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:StorageService.java

示例6: initiateStreaming

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
private void initiateStreaming()
{
    long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE;
    InetAddress dest = request.dst;
    InetAddress preferred = SystemKeyspace.getPreferredIP(dest);
    if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null)
        repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).repairedAt;
    logger.info(String.format("[streaming task #%s] Performing streaming repair of %d ranges with %s", desc.sessionId, request.ranges.size(), request.dst));
    StreamResultFuture op = new StreamPlan("Repair", repairedAt, 1)
                                .flushBeforeTransfer(true)
                                // request ranges from the remote node
                                .requestRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily)
                                // send ranges to the remote node
                                .transferRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily)
                                .execute();
    op.addEventListener(this);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:StreamingRepairTask.java

示例7: loadSchemas

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
/**
 * Load schema definitions.
 *
 * @param updateVersion true if schema version needs to be updated
 */
public static void loadSchemas(boolean updateVersion)
{
    ColumnFamilyStore schemaCFS = SystemKeyspace.schemaCFS(SystemKeyspace.SCHEMA_KEYSPACES_CF);

    // if keyspace with definitions is empty try loading the old way
    if (schemaCFS.estimateKeys() == 0)
    {
        logger.info("Couldn't detect any schema definitions in local storage.");
        // peek around the data directories to see if anything is there.
        if (hasExistingNoSystemTables())
            logger.info("Found keyspace data in data directories. Consider using cqlsh to define your schema.");
        else
            logger.info("To create keyspaces and column families, see 'help create' in cqlsh.");
    }
    else
    {
        Schema.instance.load(DefsTables.loadFromKeyspace());
    }

    if (updateVersion)
        Schema.instance.updateVersion();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:DatabaseDescriptor.java

示例8: LocalCounterIdHistory

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
LocalCounterIdHistory()
{
    CounterId id = SystemKeyspace.getCurrentLocalCounterId();
    if (id == null)
    {
        // no recorded local counter id, generating a new one and saving it
        id = generate();
        logger.info("No saved local counter id, using newly generated: {}", id);
        SystemKeyspace.writeCurrentLocalCounterId(id, FBUtilities.timestampMicros());
        current = new AtomicReference<>(id);
        olds = new CopyOnWriteArrayList<>();
    }
    else
    {
        logger.info("Saved local counter id: {}", id);
        current = new AtomicReference<>(id);
        olds = new CopyOnWriteArrayList<>(SystemKeyspace.getOldLocalCounterIds());
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:CounterId.java

示例9: prepare

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
public static PrepareResponse prepare(Commit toPrepare)
{
    synchronized (lockFor(toPrepare.key))
    {
        PaxosState state = SystemKeyspace.loadPaxosState(toPrepare.key, toPrepare.update.metadata());
        if (toPrepare.isAfter(state.promised))
        {
            Tracing.trace("Promising ballot {}", toPrepare.ballot);
            SystemKeyspace.savePaxosPromise(toPrepare);
            return new PrepareResponse(true, state.accepted, state.mostRecentCommit);
        }
        else
        {
            Tracing.trace("Promise rejected; {} is not sufficiently newer than {}", toPrepare, state.promised);
            // return the currently promised ballot (not the last accepted one) so the coordinator can make sure it uses newer ballot next time (#5667)
            return new PrepareResponse(false, state.promised, state.mostRecentCommit);
        }
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:PaxosState.java

示例10: propose

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
public static Boolean propose(Commit proposal)
{
    synchronized (lockFor(proposal.key))
    {
        PaxosState state = SystemKeyspace.loadPaxosState(proposal.key, proposal.update.metadata());
        if (proposal.hasBallot(state.promised.ballot) || proposal.isAfter(state.promised))
        {
            Tracing.trace("Accepting proposal {}", proposal);
            SystemKeyspace.savePaxosProposal(proposal);
            return true;
        }
        else
        {
            Tracing.trace("Rejecting proposal for {} because inProgress is now {}", proposal, state.promised);
            return false;
        }
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:19,代码来源:PaxosState.java

示例11: loadSchemas

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
/** load keyspace (keyspace) definitions, but do not initialize the keyspace instances. */
public static void loadSchemas()
{
    ColumnFamilyStore schemaCFS = SystemKeyspace.schemaCFS(SystemKeyspace.SCHEMA_KEYSPACES_CF);

    // if keyspace with definitions is empty try loading the old way
    if (schemaCFS.estimateKeys() == 0)
    {
        logger.info("Couldn't detect any schema definitions in local storage.");
        // peek around the data directories to see if anything is there.
        if (hasExistingNoSystemTables())
            logger.info("Found keyspace data in data directories. Consider using cqlsh to define your schema.");
        else
            logger.info("To create keyspaces and column families, see 'help create' in cqlsh.");
    }
    else
    {
        Schema.instance.load(DefsTables.loadFromKeyspace());
    }

    Schema.instance.updateVersion();
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:23,代码来源:DatabaseDescriptor.java

示例12: run

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
public void run()
{
    if (tracker != null)
        tracker.notifyDeleting(referent);

    if (referent.readMeter != null)
        SystemKeyspace.clearSSTableReadMeter(referent.getKeyspaceName(), referent.getColumnFamilyName(), referent.descriptor.generation);

    // If we can't successfully delete the DATA component, set the task to be retried later: see above
    File datafile = new File(desc.filenameFor(Component.DATA));
    if (!datafile.delete())
    {
        logger.error("Unable to delete " + datafile + " (it will be removed on server restart; we'll also retry after GC)");
        failedTasks.add(this);
        return;
    }
    // let the remainder be cleaned up by delete
    SSTable.delete(desc, Sets.difference(components, Collections.singleton(Component.DATA)));
    if (tracker != null)
        tracker.spaceReclaimed(size);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:SSTableDeletingTask.java

示例13: validate

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
    // validate login here before checkAccess to avoid leaking user existence to anonymous users.
    state.ensureNotAnonymous();

    if (!DatabaseDescriptor.getRoleManager().isExistingRole(grantee))
        throw new InvalidRequestException(String.format("Role %s doesn't exist", grantee.getRoleName()));

    // if a keyspace is omitted when GRANT/REVOKE ON TABLE <table>, we need to correct the resource.
    resource = maybeCorrectResource(resource, state);

    // altering permissions on builtin functions is not supported
    if (resource instanceof FunctionResource
        && SystemKeyspace.NAME.equals(((FunctionResource)resource).getKeyspace()))
    {
        throw new InvalidRequestException("Altering permissions on builtin functions is not supported");
    }

    if (!resource.exists())
        throw new InvalidRequestException(String.format("Resource %s doesn't exist", resource));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:PermissionsManagementStatement.java

示例14: fetchAsync

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
public StreamResultFuture fetchAsync()
{
    for (Map.Entry<String, Map.Entry<InetAddress, Collection<Range<Token>>>> entry : toFetch.entries())
    {
        String keyspace = entry.getKey();
        InetAddress source = entry.getValue().getKey();
        InetAddress preferred = SystemKeyspace.getPreferredIP(source);
        Collection<Range<Token>> ranges = entry.getValue().getValue();

        // filter out already streamed ranges
        Set<Range<Token>> availableRanges = stateStore.getAvailableRanges(keyspace, StorageService.instance.getTokenMetadata().partitioner);
        if (ranges.removeAll(availableRanges))
        {
            logger.info("Some ranges of {} are already available. Skipping streaming those ranges.", availableRanges);
        }

        if (logger.isTraceEnabled())
            logger.trace("{}ing from {} ranges {}", description, source, StringUtils.join(ranges, ", "));
        /* Send messages to respective folks to stream data over to me */
        streamPlan.requestRanges(source, preferred, keyspace, ranges);
    }

    return streamPlan.execute();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:RangeStreamer.java

示例15: handleStreamEvent

import org.apache.cassandra.db.SystemKeyspace; //导入依赖的package包/类
/**
 * When StreamSession completes, make all keyspaces/ranges in session available to be served.
 *
 * @param event Stream event.
 */
@Override
public void handleStreamEvent(StreamEvent event)
{
    if (event.eventType == StreamEvent.Type.STREAM_COMPLETE)
    {
        StreamEvent.SessionCompleteEvent se = (StreamEvent.SessionCompleteEvent) event;
        if (se.success)
        {
            for (StreamRequest request : se.requests)
            {
                SystemKeyspace.updateAvailableRanges(request.keyspace, request.ranges);
            }
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:StreamStateStore.java


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