Ejemplo n.º 1
0
  @Override
  public String getNodeForCall(String callId) {

    log.debug("Finding node for call: [%s]", callId);
    GatewayCall call = getCall(callId);
    if (call != null) {
      return call.getNodeJid();
    }
    return null;
  }
Ejemplo n.º 2
0
  private GatewayCall buildCall(List<Column> columns, String id) {

    if (columns != null && columns.size() > 0) {
      GatewayCall call = new GatewayCall();
      call.setCallId(id);
      for (Column column : columns) {
        String name = Bytes.toUTF8(column.getName());
        if (name.equals("node")) {
          call.setNodeJid(Bytes.toUTF8(column.getValue()));
        }
        if (name.equals("jid")) {
          call.setClientJid(Bytes.toUTF8(column.getValue()));
        }
      }
      return call;
    }
    return null;
  }
Ejemplo n.º 3
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;
  }
Ejemplo n.º 4
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;
  }