@Override public List<KeyspaceDefinition> internalExecute(Client client, ConnectionContext context) throws Exception { List<KsDef> ksDefs = client.describe_keyspaces(); return Lists.transform(ksDefs, new Function<KsDef, KeyspaceDefinition>() { @Override public KeyspaceDefinition apply(KsDef ksDef) { return new ThriftKeyspaceDefinitionImpl(ksDef); } }); } }, config.getRetryPolicy().duplicate()).getResult();
@Override public List<KeyspaceDefinition> internalExecute(Client client, ConnectionContext context) throws Exception { List<KsDef> ksDefs = client.describe_keyspaces(); return Lists.transform(ksDefs, new Function<KsDef, KeyspaceDefinition>() { @Override public KeyspaceDefinition apply(KsDef ksDef) { return new ThriftKeyspaceDefinitionImpl(ksDef); } }); } }, config.getRetryPolicy().duplicate()).getResult();
/** * Get a list of all known keyspaces. This method can be used with any DB connection. * * @param dbConn Database connection to use. * @return List of all known keyspaces, empty if none. */ public static Collection<String> getKeyspaces(DBConn dbConn) { List<String> result = new ArrayList<>(); try { for (KsDef ksDef : dbConn.getClientSession().describe_keyspaces()) { result.add(ksDef.getName()); } } catch (Exception e) { String errMsg = "Failed to get keyspace description"; m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } return result; } // getKeyspaces
decoder = new ColumnDecoder(client.describe_keyspaces());
KsDef inputKsDef = CliUtils.getKeySpaceDef(entityName, thriftClient.describe_keyspaces());
List<KsDef> ksDefs = client.describe_keyspaces();
List<KsDef> ksDefs = client.describe_keyspaces();
/** * Update existing keyspace identified by name * @param statement - tree represeting statement */ private void executeUpdateKeySpace(Tree statement) { if (!CliMain.isConnected()) return; try { String keyspaceName = CliCompiler.getKeySpace(statement, thriftClient.describe_keyspaces()); KsDef currentKsDef = getKSMetaData(keyspaceName); KsDef updatedKsDef = updateKsDefAttributes(statement, currentKsDef); String mySchemaVersion = thriftClient.system_update_keyspace(updatedKsDef); sessionState.out.println(mySchemaVersion); keyspacesMap.remove(keyspaceName); getKSMetaData(keyspaceName); } catch (InvalidRequestException e) { throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } }
private void executeShowSchema(Tree statement) throws TException, InvalidRequestException { if (!CliMain.isConnected()) return; printCQL3TablesWarning("show schema"); final List<KsDef> keyspaces = thriftClient.describe_keyspaces(); Collections.sort(keyspaces, new KsDefNamesComparator()); final String keyspaceName = (statement.getChildCount() == 0) ? keySpace : CliCompiler.getKeySpace(statement, keyspaces); Iterator<KsDef> ksIter; if (keyspaceName != null) ksIter = Collections2.filter(keyspaces, new Predicate<KsDef>() { public boolean apply(KsDef ksDef) { return keyspaceName.equals(ksDef.name); } }).iterator(); else ksIter = keyspaces.iterator(); while (ksIter.hasNext()) showKeyspace(sessionState.out, ksIter.next()); sessionState.out.flush(); }
/** * Delete a keyspace * @param statement - a token tree representing current statement * @throws TException - exception * @throws InvalidRequestException - exception * @throws NotFoundException - exception * @throws SchemaDisagreementException */ private void executeDelKeySpace(Tree statement) throws TException, InvalidRequestException, NotFoundException, SchemaDisagreementException { if (!CliMain.isConnected()) return; String keyspaceName = CliCompiler.getKeySpace(statement, thriftClient.describe_keyspaces()); String version = thriftClient.system_drop_keyspace(keyspaceName); sessionState.out.println(version); if (keyspaceName.equals(keySpace)) //we just deleted the keyspace we were authenticated too keySpace = null; }
/** * Get a list of all known keyspaces. This method can be used with any DB connection. * * @param dbConn Database connection to use. * @return List of all known keyspaces, empty if none. */ public Collection<String> getKeyspaces(DBConn dbConn) { List<String> result = new ArrayList<>(); try { for (KsDef ksDef : dbConn.getClientSession().describe_keyspaces()) { result.add(ksDef.getName()); } } catch (Exception e) { String errMsg = "Failed to get keyspace description"; m_logger.error(errMsg, e); throw new RuntimeException(errMsg, e); } return result; } // getKeyspaces
@Override public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException { return executeHandlingExceptions(() -> client.describe_keyspaces()); }
@Override public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException { return client.describe_keyspaces(); }
private void executeShowKeySpaces() throws TException, InvalidRequestException { if (!CliMain.isConnected()) return; printCQL3TablesWarning("show keyspaces"); List<KsDef> keySpaces = thriftClient.describe_keyspaces(); Collections.sort(keySpaces, new KsDefNamesComparator()); for (KsDef keySpace : keySpaces) { describeKeySpace(keySpace.name, keySpace); } }
@Override public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException { return client.describe_keyspaces(); }
@Override public List<KeyspaceDefinition> execute(Cassandra.Client cassandra) throws HectorException { try { return ThriftKsDef.fromThriftList(cassandra.describe_keyspaces()); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public List<KeyspaceDefinition> execute(Cassandra.Client cassandra) throws HectorException { try { return ThriftKsDef.fromThriftList(cassandra.describe_keyspaces()); } catch (Exception e) { throw xtrans.translate(e); } } };
@Override public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException { return executeHandlingExceptions(() -> client.describe_keyspaces()); }
@Override public List<KsDef> describe_keyspaces() throws InvalidRequestException, TException { return client.describe_keyspaces(); }
@Override public List<KeyspaceDefinition> execute(Cassandra.Client cassandra) throws HectorException { try { return ThriftKsDef.fromThriftList(cassandra.describe_keyspaces()); } catch (Exception e) { throw xtrans.translate(e); } } };