コード例 #1
0
  @Override
  public void deleteBindings(PersistedType type, String name, String address) throws Exception {
    Pair<PersistedType, String> key = new Pair<>(type, name);

    long tx = idGenerator.generateID();

    PersistedBindings currentBindings = mapBindings.get(key);
    if (currentBindings == null) {
      return;
    } else {
      jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId());
    }

    currentBindings.deleteBinding(address);

    if (currentBindings.getBindings().size() == 0) {
      mapBindings.remove(key);
    } else {
      long newId = idGenerator.generateID();
      currentBindings.setId(newId);
      jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings);
    }

    jmsJournal.appendCommitRecord(tx, true);
  }
コード例 #2
0
  @Override
  public void addBindings(PersistedType type, String name, String... address) throws Exception {
    Pair<PersistedType, String> key = new Pair<>(type, name);

    long tx = idGenerator.generateID();

    PersistedBindings currentBindings = mapBindings.get(key);
    if (currentBindings != null) {
      jmsJournal.appendDeleteRecordTransactional(tx, currentBindings.getId());
    } else {
      currentBindings = new PersistedBindings(type, name);
    }

    mapBindings.put(key, currentBindings);

    for (String adItem : address) {
      currentBindings.addBinding(adItem);
    }

    long newId = idGenerator.generateID();

    currentBindings.setId(newId);

    jmsJournal.appendAddRecordTransactional(tx, newId, BINDING_RECORD, currentBindings);

    jmsJournal.appendCommitRecord(tx, true);
  }
コード例 #3
0
  @Override
  public void deleteBindings(PersistedType type, String name) throws Exception {
    Pair<PersistedType, String> key = new Pair<>(type, name);

    PersistedBindings currentBindings = mapBindings.remove(key);

    if (currentBindings != null) {
      jmsJournal.appendDeleteRecord(currentBindings.getId(), true);
    }
  }
コード例 #4
0
  @Override
  public void load() throws Exception {
    mapFactories.clear();

    List<RecordInfo> data = new ArrayList<>();

    ArrayList<PreparedTransactionInfo> list = new ArrayList<>();

    jmsJournal.load(data, list, null);

    for (RecordInfo record : data) {
      long id = record.id;

      ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(record.data);

      byte rec = record.getUserRecordType();

      if (rec == CF_RECORD) {
        PersistedConnectionFactory cf = new PersistedConnectionFactory();
        cf.decode(buffer);
        cf.setId(id);
        mapFactories.put(cf.getName(), cf);
      } else if (rec == DESTINATION_RECORD) {
        PersistedDestination destination = new PersistedDestination();
        destination.decode(buffer);
        destination.setId(id);
        destinations.put(new Pair<>(destination.getType(), destination.getName()), destination);
      } else if (rec == BINDING_RECORD) {
        PersistedBindings bindings = new PersistedBindings();
        bindings.decode(buffer);
        bindings.setId(id);
        Pair<PersistedType, String> key = new Pair<>(bindings.getType(), bindings.getName());
        mapBindings.put(key, bindings);
      } else {
        throw new IllegalStateException("Invalid record type " + rec);
      }
    }
  }