Package avrobase

Examples of avrobase.AvroBaseException


    try {
      String url = datasource.getConnection().getMetaData().getURL();
      String database = url.substring(url.lastIndexOf("/") + 1);
      session = hsClient.openIndexSession(database, mysqlTableName, "PRIMARY", new String[]{"schema_id", "version", "format", "avro"});
    } catch (Exception e) {
      throw new AvroBaseException("Failed to open index", e);
    }
  }
View Full Code Here


        byte[] avro = rs.getBytes(4);
        Schema schema = getSchema(schema_id);
        if (schema != null) {
          return new Row<T, K>(readValue(avro, schema, format), keytx.fromBytes(row), version);
        } else {
          throw new AvroBaseException("Failed to find schema: " + schema_id);
        }
      } else {
        return null;
      }
    } catch (Exception e) {
      throw new AvroBaseException("Failed to retrieve row", e);
    }
  }
View Full Code Here

    ds = DatastoreServiceFactory.getDatastoreService();
    ads = DatastoreServiceFactory.getAsyncDatastoreService();
    try {
      aClass = Class.forName(readerSchema.getFullName());
    } catch (ClassNotFoundException e) {
      throw new AvroBaseException("Could not find schema class", e);
    }
    try {
      T sr = (T) aClass.newInstance();
    } catch (Exception e) {
      throw new AvroBaseException("Could not instantiate schema type", e);
    }
  }
View Full Code Here

      long schemaId = (Long) properties.get("avrobase.schema");
      Schema writerSchema = schemas.get(schemaId);
      if (writerSchema == null) {
        Entity schemaEntity = ds.get(KeyFactory.createKey(schemaEntityName, schemaId));
        if (schemaEntity == null) {
          throw new AvroBaseException("Failed to find schema: " + schemaId);
        }
        writerSchema = Schema.parse((String) schemaEntity.getProperty("schema"));
      }
      Schema schema = Schema.applyAliases(writerSchema, readerSchema);
      return new Row<T, K>((T) applyFields(entity, schema), row);
View Full Code Here

    if (row instanceof String) {
      key = KeyFactory.createKey(entityName, (String) row);
    } else if (row instanceof Long) {
      key = KeyFactory.createKey(entityName, (Long) row);
    } else {
      throw new AvroBaseException("Invalid key type: " + row.getClass().getName());
    }
    return key;
  }
View Full Code Here

  private SpecificRecord applyFields(Entity entity, Schema schema) {
    SpecificRecord sr;
    try {
      sr = (SpecificRecord) aClass.newInstance();
    } catch (Exception e) {
      throw new AvroBaseException("Failed to instantiate", e);
    }
    if (schema.getType() != Schema.Type.RECORD) {
      throw new AvroBaseException("Schema is not a record");
    }
    for (Schema.Field field : schema.getFields()) {
      sr.put(field.pos(), getValue(field.schema(), entity.getProperty(field.name())));
    }
    return sr;
View Full Code Here

        } finally {
          if (ps != null) ps.close();
          if (c != null) c.close();
        }
      } catch (SQLException e) {
        throw new AvroBaseException("Database problem", e);
      }
    }
View Full Code Here

          c = datasource.getConnection();
          ps = c.prepareStatement(statement);
          setup(ps);
          int rows = ps.executeUpdate();
          if (rows != 1) {
            throw new AvroBaseException("inserted wrong number of rows: " + rows);
          }
          ps2 = c.prepareStatement("SELECT LAST_INSERT_ID()");
          rs2 = ps2.executeQuery();
          if (rs2.next()) {
            return rs2.getInt(1);
          } else {
            throw new AvroBaseException("unexpected response");
          }
        } finally {
          if (rs2 != null) rs2.close();
          if (ps2 != null) ps2.close();
          if (ps != null) ps.close();
          if (c != null) c.close();
        }
      } catch (SQLException e) {
        throw new AvroBaseException("Database problem", e);
      }
    }
View Full Code Here

          if (rs != null) rs.close();
          if (ps != null) ps.close();
          if (c != null) c.close();
        }
      } catch (SQLException e) {
        throw new AvroBaseException("Database problem", e);
      }
    }
View Full Code Here

  public LoggingMysqlAB(ExecutorService es, DataSource datasource, String table, String family, String schemaTable, Schema schema, AvroFormat storageFormat, KeyStrategy<K> keytx) throws AvroBaseException {
    super(es, datasource, table, family, schemaTable, schema, storageFormat, keytx);
    try {
      roll();
    } catch (SQLException e) {
      throw new AvroBaseException("Could not roll log table", e);
    }
  }
View Full Code Here

TOP

Related Classes of avrobase.AvroBaseException

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.