Package avrobase

Examples of avrobase.AvroBaseException


  private Schema loadSchema(int id, byte[] value) throws AvroBaseException {
    Schema schema;
    try {
      schema = Schema.parse(new ByteArrayInputStream(value));
    } catch (IOException e) {
      throw new AvroBaseException("Could not parse the schema", e);
    }
    abbrevSchema.put(id, schema);
    schemaAbbrev.put(schema, id);
    return schema;
  }
View Full Code Here


        ps.setInt(3, format);
        ps.setBytes(4, serialize);
      }
    }.insert();
    if (updated == 0) {
      throw new AvroBaseException("Failed to save: " + updated);
    }
  }
View Full Code Here

      Document document = db.parse(url.openStream());

      // Need to get the unique key and all the fields
      NodeList uniqueKeys = document.getElementsByTagName("uniqueKey");
      if (uniqueKeys == null || uniqueKeys.getLength() != 1) {
        throw new AvroBaseException("Invalid schema configuration, must have 1 unique key");
      }
      uniqueKey = uniqueKeys.item(0).getTextContent();

      // Now get all the fields we are going to index and query
      NodeList fieldList = document.getElementsByTagName("field");
      fields = new ArrayList<String>(fieldList.getLength());
      for (int i = 0; i < fieldList.getLength(); i++) {
        Node field = fieldList.item(i);
        String name = field.getAttributes().getNamedItem("name").getTextContent();
        fields.add(name);
      }
    } catch (MalformedURLException e) {
      throw new AvroBaseException("Invalid Solr URL: " + solrURL, e);
    } catch (ParserConfigurationException e) {
      throw new AvroBaseException(e);
    } catch (SAXException e) {
      throw new AvroBaseException("Failed to parse schema", e);
    } catch (IOException e) {
      throw new AvroBaseException("Failed to read schema", e);
    }
  }
View Full Code Here

    // TODO: do we really want to throw an exception on index failure??
    try {
      solrServer.deleteById(keyTx.apply(row));
      solrServer.commit();
    } catch (SolrServerException e) {
      throw new AvroBaseException(e);
    } catch (IOException e) {
      throw new AvroBaseException(e);
    }
  }
View Full Code Here

            public K next() {
              SolrDocument solrDocument = solrDocumentIterator.next();
              Map<String, Object> map = solrDocument.getFieldValueMap();
              Object o = map.get(uniqueKey);
              if (o == null) {
                throw new AvroBaseException("Unique key not present in document");
              }

              return keyTx.unapply(o.toString());
            }

            @Override
            public void remove() {
              throw new Error("Not implemented");
            }
          };
        }
      };
    } catch (SolrServerException e) {
      throw new AvroBaseException("Query failure: " + sqh.query, e);
    }
  }
View Full Code Here

    final Iterable<K> results = search(query);

    try {
      return Iterables.getOnlyElement(results, null);
    } catch (IllegalArgumentException e) {
      throw new AvroBaseException("Too many results");
    }
  }
View Full Code Here

        req.setAction(AbstractUpdateRequest.ACTION.OPTIMIZE, false, false);
      }
      req.add(document);
      solrServer.request(req);
    } catch (SolrServerException e) {
      throw new AvroBaseException(e);
    } catch (IOException e) {
      throw new AvroBaseException(e);
    }
  }
View Full Code Here

          for (Object e : ga) {
            if (e instanceof SpecificRecord) {
              SpecificRecord sr = (SpecificRecord) e;
              addField(sr, sr.getSchema(), document, field, solrfield);
            } else {
              throw new AvroBaseException("Invalid field name" + solrfield);
            }
          }
          return;
        }
      } else {
        throw new AvroBaseException("Invalid field name" + solrfield);
      }
    }
    f = schema.getField(field);
    if (f != null) {
      Object o = value.get(f.pos());
View Full Code Here

          v = ByteBuffer.wrap((byte[]) v);
        }
        ao.put(field.pos(), v);
      }
    } catch (Exception e) {
      throw new AvroBaseException("Could not create object", e);
    }
    return ao;
  }
View Full Code Here

          statement.close();
        }
        tables.close();
      }
    } catch (Exception e) {
      throw new AvroBaseException("Could not create table: " + tableName, e);
    } finally {
      if (connection != null) try {
        connection.close();
      } catch (SQLException e) {
        throw new AvroBaseException("Could not close connection", 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.