org.apache.cassandra.config.DatabaseDescriptor Java Examples

The following examples show how to use org.apache.cassandra.config.DatabaseDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: 986499_AddColumnFamily_0_t.java    From coming with MIT License 6 votes vote down vote up
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException
{
    super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion());
    this.cfm = cfm;
    KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName);
    
    if (ksm == null)
        throw new ConfigurationException("Keyspace does not already exist.");
    else if (ksm.cfMetaData().containsKey(cfm.cfName))
        throw new ConfigurationException("CF is already defined in that keyspace.");
    else if (!Migration.isLegalName(cfm.cfName))
        throw new ConfigurationException("Invalid column family name: " + cfm.cfName);
    
    KSMetaData newKsm = makeNewKeyspaceDefinition(ksm);
    
    rm = Migration.makeDefinitionMutation(newKsm, null, newVersion);
}
 
Example #2
Source File: StorageProxy.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public static boolean shouldHint(InetAddress ep)
{
    if (DatabaseDescriptor.shouldHintByDC())
    {
        final String dc = DatabaseDescriptor.getEndpointSnitch().getDatacenter(ep);
        //Disable DC specific hints
        if(!DatabaseDescriptor.hintedHandoffEnabled(dc))
        {
            HintedHandOffManager.instance.metrics.incrPastWindow(ep);
            return false;
        }
    }
    else if (!DatabaseDescriptor.hintedHandoffEnabled())
    {
        HintedHandOffManager.instance.metrics.incrPastWindow(ep);
        return false;
    }

    boolean hintWindowExpired = Gossiper.instance.getEndpointDowntime(ep) > DatabaseDescriptor.getMaxHintWindow();
    if (hintWindowExpired)
    {
        HintedHandOffManager.instance.metrics.incrPastWindow(ep);
        Tracing.trace("Not hinting {} which has been down {}ms", ep, Gossiper.instance.getEndpointDowntime(ep));
    }
    return !hintWindowExpired;
}
 
Example #3
Source File: QueueProcessorTest.java    From debezium-incubator with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessTombstoneRecords() throws Exception {
    doNothing().when(emitter).emit(any());

    int recordSize = 5;
    ChangeEventQueue<Event> queue = context.getQueue();
    for (int i = 0; i < recordSize; i++) {
        CassandraConnectorConfig config = new CassandraConnectorConfig(Configuration.from(new Properties()));
        SourceInfo sourceInfo = new SourceInfo(config, DatabaseDescriptor.getClusterName(),
                new OffsetPosition("CommitLog-6-123.log", i),
                new KeyspaceTable(TEST_KEYSPACE, "cdc_table"), false,
                Conversions.toInstantFromMicros(System.currentTimeMillis() * 1000));
        Record record = new TombstoneRecord(sourceInfo, new RowData(), Schema.INT32_SCHEMA);
        queue.enqueue(record);
    }

    assertEquals(recordSize, queue.totalCapacity() - queue.remainingCapacity());
    queueProcessor.process();
    verify(emitter, times(recordSize)).emit(any());
    assertEquals(queue.totalCapacity(), queue.remainingCapacity());
}
 
Example #4
Source File: IndexSummaryTest.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
private Pair<List<DecoratedKey>, IndexSummary> generateRandomIndex(int size, int interval)
{
    List<DecoratedKey> list = Lists.newArrayList();
    try (IndexSummaryBuilder builder = new IndexSummaryBuilder(list.size(), interval, BASE_SAMPLING_LEVEL))
    {
        for (int i = 0; i < size; i++)
        {
            UUID uuid = UUID.randomUUID();
            DecoratedKey key = DatabaseDescriptor.getPartitioner().decorateKey(ByteBufferUtil.bytes(uuid));
            list.add(key);
        }
        Collections.sort(list);
        for (int i = 0; i < size; i++)
            builder.maybeAddEntry(list.get(i), i);
        IndexSummary summary = builder.build(DatabaseDescriptor.getPartitioner());
        return Pair.create(list, summary);
    }
}
 
Example #5
Source File: RangeStreamer.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Get a map of all ranges and their respective sources that are candidates for streaming the given ranges
 * to us. For each range, the list of sources is sorted by proximity relative to the given destAddress.
 */
private Multimap<Range<Token>, InetAddress> getAllRangesWithSourcesFor(String keyspaceName, Collection<Range<Token>> desiredRanges)
{
    AbstractReplicationStrategy strat = Keyspace.open(keyspaceName).getReplicationStrategy();
    Multimap<Range<Token>, InetAddress> rangeAddresses = strat.getRangeAddresses(metadata.cloneOnlyTokenMap());

    Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create();
    for (Range<Token> desiredRange : desiredRanges)
    {
        for (Range<Token> range : rangeAddresses.keySet())
        {
            if (range.contains(desiredRange))
            {
                List<InetAddress> preferred = DatabaseDescriptor.getEndpointSnitch().getSortedListByProximity(address, rangeAddresses.get(range));
                rangeSources.putAll(desiredRange, preferred);
                break;
            }
        }

        if (!rangeSources.keySet().contains(desiredRange))
            throw new IllegalStateException("No sources found for " + desiredRange);
    }

    return rangeSources;
}
 
Example #6
Source File: InternalMetadataFactory.java    From cassandra-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public Optional<EndpointMetadata> endpointMetadata(final InetAddress endpoint) {
    final IEndpointSnitch endpointSnitch = DatabaseDescriptor.getEndpointSnitch();

    return Optional.of(new EndpointMetadata() {
        @Override
        public String dataCenter() {
            return endpointSnitch.getDatacenter(endpoint);
        }

        @Override
        public String rack() {
            return endpointSnitch.getRack(endpoint);
        }
    });
}
 
Example #7
Source File: CommitLogSegmentManager.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Indicates that a segment file should be deleted.
 *
 * @param segment segment to be discarded
 */
private void discardSegment(final CommitLogSegment segment, final boolean deleteFile)
{
    logger.debug("Segment {} is no longer active and will be deleted {}", segment, deleteFile ? "now" : "by the archive script");
    size.addAndGet(-DatabaseDescriptor.getCommitLogSegmentSize());

    segmentManagementTasks.add(new Callable<CommitLogSegment>()
    {
        public CommitLogSegment call()
        {
            segment.close();
            if (deleteFile)
                segment.delete();
            return null;
        }
    });
}
 
Example #8
Source File: StorageProxy.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public final void run()
{

    if (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - constructionTime) > DatabaseDescriptor.getTimeout(verb))
    {
        MessagingService.instance().incrementDroppedMessages(verb);
        return;
    }
    try
    {
        runMayThrow();
    } catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
Example #9
Source File: CommitLogSegmentManager.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Differs from the above because it can work on any file instead of just existing
 * commit log segments managed by this manager.
 *
 * @param file segment file that is no longer in use.
 */
void recycleSegment(final File file)
{
    if (isCapExceeded()
        || CommitLogDescriptor.fromFileName(file.getName()).getMessagingVersion() != MessagingService.current_version)
    {
        // (don't decrease managed size, since this was never a "live" segment)
        logger.debug("(Unopened) segment {} is no longer needed and will be deleted now", file);
        FileUtils.deleteWithConfirm(file);
        return;
    }

    logger.debug("Recycling {}", file);
    // this wasn't previously a live segment, so add it to the managed size when we make it live
    size.addAndGet(DatabaseDescriptor.getCommitLogSegmentSize());
    segmentManagementTasks.add(new Callable<CommitLogSegment>()
    {
        public CommitLogSegment call()
        {
            return new CommitLogSegment(file.getPath());
        }
    });
}
 
Example #10
Source File: StorageProxy.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public final void run()
{
    if (System.currentTimeMillis() > constructionTime + DatabaseDescriptor.getTimeout(MessagingService.Verb.MUTATION))
    {
        MessagingService.instance().incrementDroppedMessages(MessagingService.Verb.MUTATION);
        HintRunnable runnable = new HintRunnable(FBUtilities.getBroadcastAddress())
        {
            protected void runMayThrow() throws Exception
            {
                LocalMutationRunnable.this.runMayThrow();
            }
        };
        submitHint(runnable);
        return;
    }

    try
    {
        runMayThrow();
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}
 
Example #11
Source File: BatchTests.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
@BeforeClass()
public static void setup() throws ConfigurationException, IOException
{
    cassandra = new EmbeddedCassandraService();
    cassandra.start();

    cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();

    session.execute("drop keyspace if exists junit;");
    session.execute("create keyspace junit WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
    session.execute("CREATE TABLE junit.noncounter (\n" +
            "  id int PRIMARY KEY,\n" +
            "  val text\n" +
            ");");
    session.execute("CREATE TABLE junit.counter (\n" +
            "  id int PRIMARY KEY,\n" +
            "  val counter,\n" +
            ");");


    noncounter = session.prepare("insert into junit.noncounter(id, val)values(?,?)");
    counter = session.prepare("update junit.counter set val = val + ? where id = ?");
}
 
Example #12
Source File: OutboundTcpConnectionPool.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example #13
Source File: FileUtils.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public static void handleFSError(FSError e)
{
    JVMStabilityInspector.inspectThrowable(e);
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
        case stop:
            StorageService.instance.stopTransports();
            break;
        case best_effort:
            // for both read and write errors mark the path as unwritable.
            BlacklistedDirectories.maybeMarkUnwritable(e.path);
            if (e instanceof FSReadError)
            {
                File directory = BlacklistedDirectories.maybeMarkUnreadable(e.path);
                if (directory != null)
                    Keyspace.removeUnreadableSSTables(directory);
            }
            break;
        case ignore:
            // already logged, so left nothing to do
            break;
        default:
            throw new IllegalStateException();
    }
}
 
Example #14
Source File: 986499_AddColumnFamily_0_s.java    From coming with MIT License 6 votes vote down vote up
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException
{
    super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion());
    this.cfm = cfm;
    KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName);
    
    if (ksm == null)
        throw new ConfigurationException("Keyspace does not already exist.");
    else if (ksm.cfMetaData().containsKey(cfm.cfName))
        throw new ConfigurationException("CF is already defined in that keyspace.");
    else if (!Migration.isLegalName(cfm.cfName))
        throw new ConfigurationException("Invalid column family name: " + cfm.cfName);
    
    KSMetaData newKsm = makeNewKeyspaceDefinition(ksm);
    
    rm = Migration.makeDefinitionMutation(newKsm, null, newVersion);
}
 
Example #15
Source File: 986499_AddColumnFamily_0_t.java    From coming with MIT License 6 votes vote down vote up
public void applyModels() throws IOException
{
    KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName);
    ksm = makeNewKeyspaceDefinition(ksm);
    try
    {
        CFMetaData.map(cfm);
    }
    catch (ConfigurationException ex)
    {
        throw new IOException(ex);
    }
    Table.open(cfm.tableName); 
    DatabaseDescriptor.setTableDefinition(ksm, newVersion);
   CFMetaData.fixMaxId();
    if (!clientMode)
        Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName);
 
    if (!clientMode)
        CommitLog.instance().forceNewSegment();
}
 
Example #16
Source File: 986499_AddColumnFamily_0_s.java    From coming with MIT License 6 votes vote down vote up
public void applyModels() throws IOException
{
    KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName);
    ksm = makeNewKeyspaceDefinition(ksm);
    try
    {
        CFMetaData.map(cfm);
    }
    catch (ConfigurationException ex)
    {
        throw new IOException(ex);
    }
    Table.open(cfm.tableName); 
    DatabaseDescriptor.setTableDefinition(ksm, newVersion);
    if (!clientMode)
        Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName);
 
    if (!clientMode)
        CommitLog.instance().forceNewSegment();
}
 
Example #17
Source File: 986499_AddColumnFamily_0_s.java    From coming with MIT License 6 votes vote down vote up
public AddColumnFamily(CFMetaData cfm) throws ConfigurationException, IOException
{
    super(UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()), DatabaseDescriptor.getDefsVersion());
    this.cfm = cfm;
    KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName);
    
    if (ksm == null)
        throw new ConfigurationException("Keyspace does not already exist.");
    else if (ksm.cfMetaData().containsKey(cfm.cfName))
        throw new ConfigurationException("CF is already defined in that keyspace.");
    else if (!Migration.isLegalName(cfm.cfName))
        throw new ConfigurationException("Invalid column family name: " + cfm.cfName);
    
    KSMetaData newKsm = makeNewKeyspaceDefinition(ksm);
    
    rm = Migration.makeDefinitionMutation(newKsm, null, newVersion);
}
 
Example #18
Source File: CommitLogTest.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
@Test
public void testCommitFailurePolicy_die()
{
    KillerForTests killerForTests = new KillerForTests();
    JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
    Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
    try
    {
        DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.die);
        CommitLog.handleCommitError("Testing die policy", new Throwable());
        Assert.assertTrue(killerForTests.wasKilled());
    }
    finally
    {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
 
Example #19
Source File: AlterUserStatement.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public void checkAccess(ClientState state) throws UnauthorizedException
{
    AuthenticatedUser user = state.getUser();

    boolean isSuper = user.isSuper();

    if (superuser != null && user.getName().equals(username))
        throw new UnauthorizedException("You aren't allowed to alter your own superuser status");

    if (superuser != null && !isSuper)
        throw new UnauthorizedException("Only superusers are allowed to alter superuser status");

    if (!user.isSuper() && !user.getName().equals(username))
        throw new UnauthorizedException("You aren't allowed to alter this user");

    if (!isSuper)
    {
        for (IAuthenticator.Option option : opts.getOptions().keySet())
        {
            if (!DatabaseDescriptor.getAuthenticator().alterableOptions().contains(option))
                throw new UnauthorizedException(String.format("You aren't allowed to alter %s option", option));
        }
    }
}
 
Example #20
Source File: 986499_AddColumnFamily_0_s.java    From coming with MIT License 6 votes vote down vote up
public void applyModels() throws IOException
{
    KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cfm.tableName);
    ksm = makeNewKeyspaceDefinition(ksm);
    try
    {
        CFMetaData.map(cfm);
    }
    catch (ConfigurationException ex)
    {
        throw new IOException(ex);
    }
    Table.open(cfm.tableName); // make sure it's init-ed w/ the old definitions first, since we're going to call initCf on the new one manually
    DatabaseDescriptor.setTableDefinition(ksm, newVersion);
    if (!clientMode)
        Table.open(ksm.name).initCf(cfm.cfId, cfm.cfName);
 
    if (!clientMode)
        CommitLog.instance().forceNewSegment();
}
 
Example #21
Source File: TermIterator.java    From sasi with Apache License 2.0 6 votes vote down vote up
public ExecutorService initialValue()
{
    final String currentThread = Thread.currentThread().getName();
    final int concurrencyFactor = DatabaseDescriptor.searchConcurrencyFactor();

    logger.info("Search Concurrency Factor is set to {} for {}", concurrencyFactor, currentThread);

    return (concurrencyFactor <= 1)
            ? MoreExecutors.sameThreadExecutor()
            : Executors.newFixedThreadPool(concurrencyFactor, new ThreadFactory()
    {
        public final AtomicInteger count = new AtomicInteger();

        @Override
        public Thread newThread(Runnable task)
        {
            return new Thread(task, currentThread + "-SEARCH-" + count.incrementAndGet()) {{ setDaemon(true); }};
        }
    });
}
 
Example #22
Source File: RowIndexEntryTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializedSize() throws IOException
{
    final RowIndexEntry simple = new RowIndexEntry(123);

    DataOutputBuffer buffer = new DataOutputBuffer();
    RowIndexEntry.Serializer serializer = new RowIndexEntry.Serializer(new SimpleDenseCellNameType(UTF8Type.instance));

    serializer.serialize(simple, buffer);

    Assert.assertEquals(buffer.getLength(), serializer.serializedSize(simple));

    buffer = new DataOutputBuffer();
    ColumnFamily cf = ArrayBackedSortedColumns.factory.create("Keyspace1", "Standard1");
    ColumnIndex columnIndex = new ColumnIndex.Builder(cf, ByteBufferUtil.bytes("a"), new DataOutputBuffer())
    {{
        int idx = 0, size = 0;
        Cell column;
        do
        {
            column = new BufferCell(CellNames.simpleDense(ByteBufferUtil.bytes("c" + idx++)), ByteBufferUtil.bytes("v"), FBUtilities.timestampMicros());
            size += column.serializedSize(new SimpleDenseCellNameType(UTF8Type.instance), TypeSizes.NATIVE);

            add(column);
        }
        while (size < DatabaseDescriptor.getColumnIndexSize() * 3);

    }}.build();

    RowIndexEntry withIndex = RowIndexEntry.create(0xdeadbeef, DeletionTime.LIVE, columnIndex);

    serializer.serialize(withIndex, buffer);
    Assert.assertEquals(buffer.getLength(), serializer.serializedSize(withIndex));
}
 
Example #23
Source File: PerRowSecondaryIndexTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Override
public void index(ByteBuffer rowKey, ColumnFamily cf)
{
    QueryFilter filter = QueryFilter.getIdentityFilter(DatabaseDescriptor.getPartitioner().decorateKey(rowKey),
                                                       baseCfs.getColumnFamilyName(),
                                                       System.currentTimeMillis());
    LAST_INDEXED_ROW = cf;
    LAST_INDEXED_KEY = rowKey;
}
 
Example #24
Source File: BootStrapper.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * if initialtoken was specified, use that (split on comma).
 * otherwise, if num_tokens == 1, pick a token to assume half the load of the most-loaded node.
 * else choose num_tokens tokens at random
 */
public static Collection<Token> getBootstrapTokens(final TokenMetadata metadata) throws ConfigurationException
{
    Collection<String> initialTokens = DatabaseDescriptor.getInitialTokens();
    // if user specified tokens, use those
    if (initialTokens.size() > 0)
    {
        logger.debug("tokens manually specified as {}",  initialTokens);
        List<Token> tokens = new ArrayList<Token>(initialTokens.size());
        for (String tokenString : initialTokens)
        {
            Token token = StorageService.getPartitioner().getTokenFactory().fromString(tokenString);
            if (metadata.getEndpoint(token) != null)
                throw new ConfigurationException("Bootstrapping to existing token " + tokenString + " is not allowed (decommission/removenode the old node first).");
            tokens.add(token);
        }
        return tokens;
    }

    int numTokens = DatabaseDescriptor.getNumTokens();
    if (numTokens < 1)
        throw new ConfigurationException("num_tokens must be >= 1");

    if (numTokens == 1)
        logger.warn("Picking random token for a single vnode.  You should probably add more vnodes; failing that, you should probably specify the token manually");

    return getRandomTokens(metadata, numTokens);
}
 
Example #25
Source File: Auth.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/**
 * Sets up Authenticator and Authorizer.
 */
public static void setup()
{
    if (DatabaseDescriptor.getAuthenticator() instanceof AllowAllAuthenticator)
        return;

    setupAuthKeyspace();
    setupTable(USERS_CF, USERS_CF_SCHEMA);

    DatabaseDescriptor.getAuthenticator().setup();
    DatabaseDescriptor.getAuthorizer().setup();

    // register a custom MigrationListener for permissions cleanup after dropped keyspaces/cfs.
    MigrationManager.instance.register(new AuthMigrationListener());

    // the delay is here to give the node some time to see its peers - to reduce
    // "Skipped default superuser setup: some nodes were not ready" log spam.
    // It's the only reason for the delay.
    ScheduledExecutors.nonPeriodicTasks.schedule(new Runnable()
    {
        public void run()
        {
            setupDefaultSuperuser();
        }
    }, SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS);

    try
    {
        String query = String.format("SELECT * FROM %s.%s WHERE name = ?", AUTH_KS, USERS_CF);
        selectUserStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement;
    }
    catch (RequestValidationException e)
    {
        throw new AssertionError(e); // not supposed to happen
    }
}
 
Example #26
Source File: AbstractEndpointSnitch.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
private boolean hasRemoteNode(List<InetAddress> l)
{
    String localDc = DatabaseDescriptor.getLocalDataCenter();
    for (InetAddress ep : l)
    {
        if (!localDc.equals(getDatacenter(ep)))
            return true;
    }
    return false;
}
 
Example #27
Source File: CreateUserStatement.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public ResultMessage execute(ClientState state) throws RequestValidationException, RequestExecutionException
{
    // not rejected in validate()
    if (ifNotExists && Auth.isExistingUser(username))
        return null;

    DatabaseDescriptor.getAuthenticator().create(username, opts.getOptions());
    Auth.insertUser(username, superuser);
    return null;
}
 
Example #28
Source File: JVMStabilityInspector.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public static void inspectCommitLogThrowable(Throwable t)
{
    if (DatabaseDescriptor.getCommitFailurePolicy() == Config.CommitFailurePolicy.die)
        killer.killCurrentJVM(t);
    else
        inspectThrowable(t);
}
 
Example #29
Source File: DropUserStatement.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public ResultMessage execute(ClientState state) throws RequestValidationException, RequestExecutionException
{
    // not rejected in validate()
    if (ifExists && !Auth.isExistingUser(username))
        return null;

    // clean up permissions after the dropped user.
    DatabaseDescriptor.getAuthorizer().revokeAll(username);
    Auth.deleteUser(username);
    DatabaseDescriptor.getAuthenticator().drop(username);
    return null;
}
 
Example #30
Source File: SimpleSeedProvider.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public List<InetAddress> getSeeds()
{
    Config conf;
    try
    {
        conf = DatabaseDescriptor.loadConfig();
    }
    catch (Exception e)
    {
        throw new AssertionError(e);
    }
    String[] hosts = conf.seed_provider.parameters.get("seeds").split(",", -1);
    List<InetAddress> seeds = new ArrayList<InetAddress>(hosts.length);
    for (String host : hosts)
    {
        try
        {
            seeds.add(InetAddress.getByName(host.trim()));
        }
        catch (UnknownHostException ex)
        {
            // not fatal... DD will bark if there end up being zero seeds.
            logger.warn("Seed provider couldn't lookup host {}", host);
        }
    }
    return Collections.unmodifiableList(seeds);
}