Package avrobase

Examples of avrobase.AvroBaseException


        put.add(AVRO_FAMILY, SCHEMA_COLUMN, $(doc));
        HTableInterface schemaTable = pool.getTable(schemaName);
        try {
          schemaTable.put(put);
        } catch (IOException e) {
          throw new AvroBaseException("Could not store schema " + doc, e);
        } finally {
          pool.putTable(schemaTable);
        }
      }
    }
View Full Code Here


  // Load a schema from the current hbase row

  private Schema loadSchema(final byte[] row, final byte[] schemaKey, int offset, int length) throws AvroBaseException, IOException {
    if (schemaKey == null) {
      throw new AvroBaseException("Schema not set for row: " + $_(row));
    }
    Schema schema = schemaCache.get($_(schemaKey, offset, length));
    if (schema == null) {
      HTableInterface schemaTable = pool.getTable(schemaName);
      try {
        Get schemaGet = new Get(schemaKey);
        schemaGet.addColumn(AVRO_FAMILY, SCHEMA_COLUMN);
        byte[] schemaBytes = schemaTable.get(schemaGet).getValue(AVRO_FAMILY, SCHEMA_COLUMN);
        if (schemaBytes == null) {
          throw new AvroBaseException("No schema " + $_(schemaKey) + " found in hbase for row " + $_(row));
        }
        schema = loadSchema(schemaBytes, $_(schemaKey));
      } finally {
        pool.putTable(schemaTable);
      }
View Full Code Here

        }
      } finally {
        if (connection != null) connection.close();
      }
    } catch (SQLException sqle) {
      throw new AvroBaseException("Problem with MySQL", sqle);
    }
  }
View Full Code Here

        HTableDescriptor tableDesc = new HTableDescriptor(tableName);
        tableDesc.addFamily(familyDesc);
        try {
          admin.createTable(tableDesc);
        } catch (IOException e1) {
          throw new AvroBaseException(e1);
        }
      } else {
        throw new AvroBaseException(e.getCause());
      }
      table = pool.getTable(tableName);
    }
    return table;
  }
View Full Code Here

  @Override
  public K create(T value) throws AvroBaseException {
    final K key = keytx.newKey();
    if (!put(key, value, 0)) {
      throw new AvroBaseException("did not add " + key);
    } else {
      return key;
    }
  }
View Full Code Here

          byte[] bytes = rs.getBytes(5);
          try {
            dos.writeBoolean(true);
            writeRow(dos, row, schemaId, version, format, bytes);
          } catch (IOException e) {
            throw new AvroBaseException("Could not write", e);
          }
        }
        return null;
      }
    }.query();
    try {
      dos.writeBoolean(false);
    } catch (IOException e) {
      throw new AvroBaseException("Could not closing boolean", e);
    }
  }
View Full Code Here

    try {
      dos.writeBoolean(true);
      writeSchemas(dos);
      dos.writeBoolean(false);
    } catch (Exception e) {
      throw new AvroBaseException(e);
    }
  }
View Full Code Here

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

    } catch (IOException e) {
      throw new AvroBaseException("Failed to read", e);
    }
  }
View Full Code Here

            ps.setBytes(3, json);
          }
        }.insert();
      }
    } catch (IOException e) {
      throw new AvroBaseException("Failed to read", 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;
        }
      }
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.