Package org.kiji.schema

Examples of org.kiji.schema.KijiIOException


  public static DefaultCassandraAdmin makeFromKijiURI(KijiURI kijiURI) {
    CassandraKijiURI cassandraKijiURI;
    if (kijiURI instanceof CassandraKijiURI) {
       cassandraKijiURI = (CassandraKijiURI) kijiURI;
    } else {
      throw new KijiIOException("Need a Cassandra URI for a CassandraAdmin.");
    }
    final List<String> hosts = cassandraKijiURI.getContactPoints();
    final String[] hostStrings = hosts.toArray(new String[hosts.size()]);
    int port = cassandraKijiURI.getContactPort();
    final Cluster.Builder clusterBuilder = Cluster
View Full Code Here


      LOG.debug("URI is a fake C* URI -> Creating FakeCassandraAdminFactory...");
      // Make sure that the EmbeddedCassandraService is started
      try {
        startEmbeddedCassandraServiceIfNotRunningAndOpenSession();
      } catch (Exception e) {
        throw new KijiIOException("Problem with embedded Cassandra Session! " + e);
      }
      // Get an admin factory that will work with the embedded service
      return createFakeCassandraAdminFactory();
    } else {
      LOG.debug("URI is not a fake Cassandra URI.");
View Full Code Here

      }
      EmbeddedCassandraService embeddedCassandraService = new EmbeddedCassandraService();
      embeddedCassandraService.start();

    } catch (IOException ioe) {
      throw new KijiIOException("Cannot start embedded C* service!");
    }

    try {
      // Use different port from normal here to avoid conflicts with any locally-running C* cluster.
      // Port settings are controlled in "cassandra.yaml" in test resources.
      // Also change the timeouts and retry policies.  Since we have only a single thread here for
      // this test process, it can slow down dramatically if it has to do a compaction (see
      // SCHEMA-959 and SCHEMA-969 for examples of the flakiness this case cause in unit tests).

      // No builder for `SocketOptions`:
      final SocketOptions socketOptions = new SocketOptions();
      // Setting this to 0 disables read timeouts.
      socketOptions.setReadTimeoutMillis(0);
      // This defaults to 5 s.  Increase to a minute.
      socketOptions.setConnectTimeoutMillis(60 * 1000);


      Cluster cluster = Cluster.builder()
          .addContactPoints(DatabaseDescriptor.getListenAddress())
          .withPort(DatabaseDescriptor.getNativeTransportPort())
          .withSocketOptions(socketOptions)
          // Let's at least log all of the retries so we can see what is happening.
          .withRetryPolicy(new LoggingRetryPolicy(Policies.defaultRetryPolicy()))
          // The default reconnection policy (exponential) looks fine.
          .build();
      mCassandraSession = cluster.connect();
    } catch (Exception exc) {
      throw new KijiIOException(
          "Started embedded C* service, but cannot connect to cluster. " + exc);
    }
  }
View Full Code Here

    if (avroSchema.getJson() != null) {
      final Schema schema = new Schema.Parser().parse(avroSchema.getJson());
      try {
        return mSchemaTable.getOrCreateSchemaId(schema);
      } catch (IOException ioe) {
        throw new KijiIOException(ioe);
      }
    } else if (avroSchema.getUid() != null) {
      return avroSchema.getUid();
    } else {
      throw new KijiIOException(
          "AvroSchema neither has a schema UID nor a schema JSON descriptor.");
    }
  }
View Full Code Here

      return new Schema.Parser().parse(avroSchema.getJson());
    } else if (avroSchema.getUid() != null) {
      try {
        final Schema schema = mSchemaTable.getSchema(avroSchema.getUid());
        if (schema == null) {
          throw new KijiIOException(String.format(
              "Schema UID %d unknown in Kiji instance '%s'.",
              avroSchema.getUid(), mSchemaTable));
        }
        return schema;
      } catch (IOException ioe) {
        throw new KijiIOException(ioe);
      }
    } else {
      throw new KijiIOException(
          "AvroSchema neither has a schema UID nor a schema JSON descriptor.");
    }
  }
View Full Code Here

    final ObjectMapper mapper = new ObjectMapper();
    try {
      final JsonNode root = mapper.readTree(json);
      return toFilter(root);
    } catch (IOException ioe) {
      throw new KijiIOException(ioe);
    }
  }
View Full Code Here

      final KijiRowFilterDeserializer filterDeserializer =
          (KijiRowFilterDeserializer) filterDeserializerClass.newInstance();
      final KijiRowFilter filter = filterDeserializer.createFromJson(root.path(FILTER_NODE));
      return filter;
    } catch (ClassNotFoundException cnfe) {
      throw new KijiIOException(cnfe);
    } catch (IllegalAccessException iae) {
      throw new KijiIOException(iae);
    } catch (InstantiationException ie) {
      throw new KijiIOException(ie);
    }
  }
View Full Code Here

  @Override
  public HConnection getHConnection(Kiji kiji) {
    try {
      return HConnectionManager.createConnection(kiji.getConf());
    } catch (IOException ioe) {
      throw new KijiIOException("Couldn't create an HConnection.", ioe);
    }
  }
View Full Code Here

    Preconditions.checkState(state == State.OPEN,
        "Cannot open a table reader on a KijiTable in state %s.", state);
    try {
      return HBaseKijiTableReader.create(this);
    } catch (IOException ioe) {
      throw new KijiIOException(ioe);
    }
  }
View Full Code Here

    Preconditions.checkState(state == State.OPEN,
        "Cannot open a table writer on a KijiTable in state %s.", state);
    try {
      return new HBaseKijiTableWriter(this);
    } catch (IOException ioe) {
      throw new KijiIOException(ioe);
    }
  }
View Full Code Here

TOP

Related Classes of org.kiji.schema.KijiIOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.