示例#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;
  }
示例#2
0
  @Override
  public GatewayCall removeCall(String id) throws DatastoreException {

    log.debug("Removing call with id: [%s]", id);
    GatewayCall call = getCall(id);

    if (call != null) {
      Mutator mutator = Pelops.createMutator(schemaName);
      mutator.deleteSubColumns("jids", "clients", call.getClientJid(), id);
      mutator.deleteSubColumns("jids", "nodes", call.getNodeJid(), id);

      try {
        RowDeletor deletor = Pelops.createRowDeletor(schemaName);
        deletor.deleteRow("calls", Bytes.fromUTF8(id), ConsistencyLevel.ONE);

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