本文整理汇总了Java中com.netflix.astyanax.connectionpool.exceptions.ConnectionException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionException.printStackTrace方法的具体用法?Java ConnectionException.printStackTrace怎么用?Java ConnectionException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.astyanax.connectionpool.exceptions.ConnectionException
的用法示例。
在下文中一共展示了ConnectionException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupKeyspace
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
private void setupKeyspace()
{
try {
//if(keyspace.describeKeyspace() == null) {
keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
.put("strategy_options", ImmutableMap.<String, Object>builder()
.put("replication_factor", "1")
.build())
.put("strategy_class", "SimpleStrategy")
.build()
);
//}
} catch (ConnectionException e) {
//todo the column gets throw if the keyspace exists already I have to filter out this error
e.printStackTrace();
}
}
示例2: setupColumnFamilies
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
private void setupColumnFamilies()
{
this.scheduledUrlColumn = ColumnFamily
.newColumnFamily(SCHEDULED_COLUMN_NAME, LongSerializer.get(),
StringSerializer.get());
this.crawledUrlColumn = ColumnFamily
.newColumnFamily(CRAWLED_COLUMN_NAME, IntegerSerializer.get(),
StringSerializer.get());
this.robotsTxtColumn = ColumnFamily
.newColumnFamily(ROBOTSTXT_COLUMN_NAME, StringSerializer.get(),
StringSerializer.get());
this.hostColumn = ColumnFamily.newColumnFamily(HOST_COLUMN_NAME, StringSerializer.get(), StringSerializer.get());
try {
keyspace.createColumnFamily(crawledUrlColumn, null);
keyspace.createColumnFamily(scheduledUrlColumn, null);
keyspace.createColumnFamily(robotsTxtColumn, null);
keyspace.createColumnFamily(hostColumn, null);
} catch (ConnectionException e) {
e.printStackTrace();
}
}
示例3: handleTuple
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
@Override
public void handleTuple(ITuple tuple) {
MutationBatch m = keyspace.prepareMutationBatch();
if (! getProperties().containsKey(INCREMENT)){
m.withRow(new ColumnFamily((String) properties.get(COLUMN_FAMILY),
ByteBufferSerializer.get(),
ByteBufferSerializer.get()),
(ByteBuffer) tuple.getField(ROW_KEY))
.putColumn((ByteBuffer) tuple.getField(COLUMN), (ByteBuffer) tuple.getField(VALUE));
} else {
m.withRow(new ColumnFamily((String) properties.get(COLUMN_FAMILY),
ByteBufferSerializer.get(),
ByteBufferSerializer.get()),
(ByteBuffer) tuple.getField(ROW_KEY))
.incrementCounterColumn((ByteBuffer) tuple.getField(COLUMN),((Number) tuple.getField(VALUE) ).longValue());
}
try {
OperationResult<Void> result = m.execute();
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例4: handleTuple
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
@Override
public void handleTuple(ITuple tuple) {
if (! getProperties().containsKey(INCREMENT)){
m.withRow(new ColumnFamily((String) properties.get(COLUMN_FAMILY),
ByteBufferSerializer.get(),
ByteBufferSerializer.get()),
(ByteBuffer) tuple.getField(ROW_KEY))
.putColumn((ByteBuffer) tuple.getField(COLUMN), (ByteBuffer) tuple.getField(VALUE));
} else {
m.withRow(new ColumnFamily((String) properties.get(COLUMN_FAMILY),
ByteBufferSerializer.get(),
ByteBufferSerializer.get()),
(ByteBuffer) tuple.getField(ROW_KEY))
.incrementCounterColumn((ByteBuffer) tuple.getField(COLUMN),((Number) tuple.getField(VALUE) ).longValue());
}
count++;
if (count % batchSize == 0){
try {
OperationResult<Void> result = m.execute();
} catch (ConnectionException e) {
e.printStackTrace();
}
m = keyspace.prepareMutationBatch();
}
}
示例5: writeMetaEntity
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
@Override
public void writeMetaEntity(Entity entity) {
// TODO Auto-generated method stub
Keyspace ks = kscp.acquireKeyspace("meta");
ks.prepareMutationBatch();
MutationBatch m;
OperationResult<Void> result;
m = ks.prepareMutationBatch();
m.withRow(dbcf, entity.getRowKey()).putColumn(entity.getName(), entity.getPayLoad(), null);
try {
result = m.execute();
if (entity instanceof PaasTableEntity) {
String schemaName = ((PaasTableEntity)entity).getSchemaName();
Keyspace schemaks = kscp.acquireKeyspace(schemaName);
ColumnFamily<String, String> cf = ColumnFamily.newColumnFamily(entity.getName(), StringSerializer.get(), StringSerializer.get());
schemaks.createColumnFamily(cf, null);
}
int i = 0;
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: getData
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
public String getData(String row)
{
OperationResult<ColumnList<String>> result = null;
try
{
result = keyspace.prepareQuery(CF_SESSIONS).getKey(row).execute();
}
catch(ConnectionException e1)
{
e1.printStackTrace();
}
ColumnList<String> columns = (ColumnList<String>)result.getResult();
Column<String> c = columns.getColumnByName("page");
String value = null;
if(c != null)
value = c.getStringValue();
return value;
}
示例7: store
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
@Override
public void store(String s, Long aLong) {
try {
keyspace.prepareColumnMutation(cluster.getHostColumn(), s, VALUE_COLUMN)
.putValue(aLong, null)
.execute();
} catch (ConnectionException e) {
e.printStackTrace();
}
}
示例8: createDirectory
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
public void createDirectory(String path) {
path = StringUtils.chomp(path, "/");
if (StringUtils.isEmpty(path)) {
return;
}
try {
String tmpPath = path;
UUID rootDir = ROOT_UUID;
do {
final String[] directories = StringUtils.split(removeFirstSlash(tmpPath), "/", 2);
if (StringUtils.isEmpty(ArrayUtils.get(directories, 0))) {
break;
}
final String directoryName = directories[0];
final UUID resourceUUID = getResourceUUID(rootDir, directoryName);
if (resourceUUID != null) {
rootDir = resourceUUID;
} else {
createSubdirectory(rootDir, directoryName);
}
tmpPath = ArrayUtils.get(directories, 1);
} while (true);
} catch (ConnectionException e) {
e.printStackTrace();
}
}
示例9: write
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
public void write(TimedGroupEntry e){
MutationBatch m = keyspace.prepareMutationBatch();
DateFormat byMinuteDateFormat = newByMinuteDateFormat();
DateFormat byHourDateFormat = newByHourDateFormat();
DateFormat byDayDateFormat = newByDayDateFormat();
for (List<String> group : e.getGroups()) {
StringBuilder column = new StringBuilder();
StringBuilder value = new StringBuilder();
for (int i = 0; i < group.size(); i++) {
column.append(group.get(i));
value.append(e.getEventProperties().get(group.get(i)));
if (i < group.size() - 1) {
column.append("+");
value.append("+");
}
}
StringBuilder end = new StringBuilder().append(column).append("#").append(value);
m.withRow(byMinute, byMinuteDateFormat.format(new Date(e.getEventTimeInMillis()))).incrementCounterColumn(end.toString(), e.getIncrementValue());
m.withRow(byHour, byHourDateFormat.format(new Date(e.getEventTimeInMillis()))).incrementCounterColumn(end.toString(), e.getIncrementValue());
m.withRow(byDay, byDayDateFormat.format(new Date(e.getEventTimeInMillis()))).incrementCounterColumn(end.toString(), e.getIncrementValue());
}
try {
OperationResult<Void> result = m.execute();
} catch (ConnectionException ex) {
ex.printStackTrace();
}
}
示例10: runQuery
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
public Map<String, JsonObject> runQuery(String key, String col) {
OperationResult<CqlStatementResult> rs;
Map<String, JsonObject> resultMap = new HashMap<String, JsonObject>();
try {
String queryStr = "";
if (col != null && !col.equals("*")) {
queryStr = "select column1, value from "+MetaConstants.META_KEY_SPACE + "." + MetaConstants.META_COLUMN_FAMILY +" where key='"
+ key + "' and column1='" + col + "';";
} else {
queryStr = "select column1, value from "+MetaConstants.META_KEY_SPACE + "." + MetaConstants.META_COLUMN_FAMILY +" where key='"
+ key + "';";
}
rs = keyspace.prepareCqlStatement().withCql(queryStr).execute();
for (Row<String, String> row : rs.getResult().getRows(METACF)) {
ColumnList<String> columns = row.getColumns();
String key1 = columns.getStringValue("column1", null);
String val1 = columns.getStringValue("value", null);
resultMap.put(key1, new JsonObject(val1));
}
} catch (ConnectionException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
return resultMap;
}
示例11: listRows
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
@Override
public QueryResult listRows(String cursor, Integer rowLimit, Integer columnLimit) throws PaasException {
try {
invariant();
// Execute the query
Partitioner partitioner = keyspace.getPartitioner();
Rows<ByteBuffer, ByteBuffer> result = keyspace
.prepareQuery(columnFamily)
.getKeyRange(null, null, cursor != null ? cursor : partitioner.getMinToken(), partitioner.getMaxToken(), rowLimit)
.execute()
.getResult();
// Convert raw data into a simple sparse tree
SchemalessRows.Builder builder = SchemalessRows.builder();
for (Row<ByteBuffer, ByteBuffer> row : result) {
Map<String, String> columns = Maps.newHashMap();
for (Column<ByteBuffer> column : row.getColumns()) {
columns.put(serializers.columnAsString(column.getRawName()), serializers.valueAsString(column.getRawName(), column.getByteBufferValue()));
}
builder.addRow(serializers.keyAsString(row.getKey()), columns);
}
QueryResult dr = new QueryResult();
dr.setSrows(builder.build());
if (!result.isEmpty()) {
dr.setCursor(partitioner.getTokenForKey(Iterables.getLast(result).getKey()));
}
return dr;
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
示例12: addData
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
public void addData(String key, String value, int ttl)
{
MutationBatch mb = keyspace.prepareMutationBatch();
mb.withRow(CF_SESSIONS, key).putColumn("page", value, Integer.valueOf(ttl));
try
{
mb.execute();
}
catch(ConnectionException e)
{
e.printStackTrace();
}
}
示例13: queryByDay
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
public List<Map<String,String>> queryByDay(Date start, String sliceStart, String sliceEnd){
String rowKey = TimedGroupByEngine.newByHourDateFormat().format(start);
ColumnList<String> result = null;
List<Map<String,String>> results = new ArrayList<>();
try {
result = keyspace.prepareQuery(TimedGroupByEngine.byHour)
.getKey(rowKey).withColumnRange(sliceStart, sliceEnd, false, 10000)
.execute().getResult();
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Map<String, String> oneRow = new HashMap<String, String>();
oneRow.put("timeInMillis", start.getTime() + "");
for (String name : result.getColumnNames()){
System.out.println(name + " " + result.getColumnByName(name).getLongValue());
oneRow.put(name.split("#")[1], result.getColumnByName(name).getLongValue()+"");
}
results.add(oneRow);
return results;
/*
host+metric#web1+hits 22
host#web1 22
metric#hits 22
metric+host#hits+web1 22 */
/*
ColumnList<String> result = keyspace.prepareQuery(TimedGroupByEngine.byHour)
.getKey(rowKey)
.execute().getResult();
*/
//stats[yyyy--mm--dd][mm+eventName#eventValue]=7
//stats[yyyy--mm--dd][mm+age+weight#21+180]=7
//StatsByMinute[yyyy-mm-dd-hh-mm][age+weight#20]
//StatsByHour[yyyy-mm-dd-hh][age+weight#20]
//StatsByDay[yyyy-mm-dd][age+weight#20]
}
示例14: embeddedCassandrSetup
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
@BeforeClass
public static void embeddedCassandrSetup() throws TTransportException, IOException,
InterruptedException, ConfigurationException {
if (started == null) {
started = new Object();
EmbeddedCassandraServerHelper e = new EmbeddedCassandraServerHelper();
e.startEmbeddedCassandra("/cassandra.yaml");
AstyanaxContext<Cluster> clusterContext = new AstyanaxContext.Builder()
.forCluster("localhost:9157")
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl())
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl("ClusterName").setMaxConnsPerHost(1)
.setSeeds("localhost:9157"))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildCluster(ThriftFamilyFactory.getInstance());
clusterContext.start();
Cluster cluster = clusterContext.getEntity();
context = new AstyanaxContext.Builder()
.forCluster("ClusterName")
.forKeyspace(KEYSPACE)
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl("MyConnectionPool").setPort(9157)
.setMaxConnsPerHost(1).setSeeds("localhost:9157"))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
keyspace = context.getEntity();
try {
keyspace.createKeyspace(ImmutableMap
.<String, Object> builder()
.put("strategy_options",
ImmutableMap.<String, Object> builder().put("replication_factor", "1")
.build()).put("strategy_class", "SimpleStrategy").build());
ColumnFamily<Byte, Byte> CF_STANDARD1 = ColumnFamily.newColumnFamily(COLUMNFAMILY,
ByteSerializer.get(), ByteSerializer.get());
keyspace.createColumnFamily(CF_STANDARD1, null);
cluster.addColumnFamily(cluster.makeColumnFamilyDefinition().setName("StatsByMinute")
.setDefaultValidationClass("CounterColumnType").setKeyValidationClass("UTF8Type")
.setComparatorType("UTF8Type").setKeyspace(KEYSPACE));
cluster.addColumnFamily(cluster.makeColumnFamilyDefinition().setName("StatsByHour")
.setDefaultValidationClass("CounterColumnType").setKeyValidationClass("UTF8Type")
.setComparatorType("UTF8Type").setKeyspace(KEYSPACE));
cluster.addColumnFamily(cluster.makeColumnFamilyDefinition().setName("StatsByDay")
.setDefaultValidationClass("CounterColumnType").setKeyValidationClass("UTF8Type")
.setComparatorType("UTF8Type").setKeyspace(KEYSPACE));
} catch (ConnectionException ex) {
ex.printStackTrace();
}
}
}
示例15: acquireKeyspace
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; //导入方法依赖的package包/类
@Override
public synchronized Keyspace acquireKeyspace(String schemaName) {
schemaName = schemaName.toLowerCase();
Preconditions.checkNotNull(schemaName, "Invalid schema name 'null'");
KeyspaceContextHolder holder = contextMap.get(schemaName);
if (holder == null) {
LOG.info("Creating schema for '{}'", new Object[]{schemaName});
String clusterName = configuration.getString(String.format(CLUSTER_NAME_FORMAT, schemaName));
String keyspaceName = configuration.getString(String.format(KEYSPACE_NAME__FORMAT, schemaName));
String discoveryType = configuration.getString(String.format(DISCOVERY_TYPE_FORMAT, schemaName));
if (clusterName==null || clusterName.equals("")) clusterName = configuration.getString(String.format(CLUSTER_NAME_FORMAT, "configuration"));
if (keyspaceName == null || keyspaceName.equals("")) keyspaceName = schemaName;
if (discoveryType==null || discoveryType.equals("")) discoveryType = configuration.getString(String.format(DISCOVERY_TYPE_FORMAT, "configuration"));
Preconditions.checkNotNull(clusterName, "Missing cluster name for schema " + schemaName + " " + String.format(CLUSTER_NAME_FORMAT,schemaName));
Preconditions.checkNotNull(keyspaceName, "Missing cluster name for schema " + schemaName + " " + String.format(KEYSPACE_NAME__FORMAT,schemaName));
Preconditions.checkNotNull(discoveryType, "Missing cluster name for schema " + schemaName + " " + String.format(DISCOVERY_TYPE_FORMAT,schemaName));
HostSupplierProvider hostSupplierProvider = hostSupplierProviders.get(discoveryType);
Preconditions.checkNotNull(hostSupplierProvider,
String.format("Unknown host supplier provider '%s' for schema '%s'", discoveryType, schemaName));
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(clusterName)
.forKeyspace(keyspaceName)
.withAstyanaxConfiguration(configurationProvider.get(schemaName))
.withConnectionPoolConfiguration(cpProvider.get(schemaName))
.withConnectionPoolMonitor(monitorProvider.get(schemaName))
.withHostSupplier(hostSupplierProvider.getSupplier(clusterName))
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
try {
context.getClient().createKeyspace(defaultKsOptions);
} catch (ConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
holder = new KeyspaceContextHolder(context);
contextMap.put(schemaName, holder);
holder.start();
}
holder.addRef();
return holder.getKeyspace();
}