Example #1
0
  @Override
  public GatewayCall storeCall(GatewayCall call) throws DatastoreException {

    log.debug("Storing call: [%s]", call);
    RayoNode node = getNode(call.getNodeJid());
    if (node == null) {
      log.debug("Node [%s] not found for call [%s]", call.getNodeJid(), call);
      throw new RayoNodeNotFoundException();
    }

    Mutator mutator = Pelops.createMutator(schemaName);
    mutator.writeColumns(
        "calls",
        Bytes.fromUTF8(call.getCallId()),
        mutator.newColumnList(
            mutator.newColumn(Bytes.fromUTF8("jid"), Bytes.fromUTF8(call.getClientJid())),
            mutator.newColumn(Bytes.fromUTF8("node"), Bytes.fromUTF8(call.getNodeJid()))));

    mutator.writeSubColumn(
        "jids",
        "clients",
        Bytes.fromUTF8(call.getClientJid()),
        mutator.newColumn(Bytes.fromUTF8(call.getCallId()), Bytes.fromUTF8(call.getCallId())));
    mutator.writeSubColumn(
        "jids",
        "nodes",
        Bytes.fromUTF8(call.getNodeJid()),
        mutator.newColumn(Bytes.fromUTF8(call.getCallId()), Bytes.fromUTF8(call.getCallId())));

    try {
      mutator.execute(ConsistencyLevel.ONE);
      log.debug("Call [%s] stored successfully", call);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new DatastoreException("Could not store call");
    }

    return call;
  }