Esempio n. 1
0
DysectAPI::DysectErrorCode Backend::prepareProbes(struct DysectBEContext_t* context) {
  assert(context);
  assert(context->walkerSet);

  walkerSet = context->walkerSet;

  Domain::setBEContext(context);

  DysectAPI::DaemonHostname = context->hostname;

  vector<Probe*> roots = ProbeTree::getRoots();

  for(int i = 0; i < roots.size(); i++) {
    Probe* probe = roots[i];

    // Prepare all streams ie. ensure all domain ids and tags are created
    // for stream -> domain binding
    if(probe->prepareStream(recursive) != OK) {
      Err::warn(Error, "Error occured while preparing streams");
    }

    if(probe->prepareEvent(recursive) != OK) {
      Err::warn(Error, "Error occured while preparing events");
    }

    Err::verbose(true, "Starting preparation of conditions");
    
    if(probe->prepareCondition(recursive) != OK) {
      Err::warn(Error, "Error occured while preparing conditions");
    }

    if(probe->prepareAction(recursive) != OK) {
      Err::warn(Error, "Error occured while preparing actions");
    }
  }

  // Add all domains to missing bindings
  map<tag_t, Domain*> domainMap = Domain::getDomainMap();
  map<tag_t, Domain*>::iterator domainIter = domainMap.begin();
  for(;domainIter != domainMap.end(); domainIter++) {
    tag_t domainId = domainIter->first;

    Domain* dom = domainIter->second;

    if(dom->anyTargetsAttached()) {
      Err::verbose(true, "Missing domain: %x", domainId);
      missingBindings.insert(domainId);
    }
  }
  
  // List generated - wait for incoming frontend init packages

  if(missingBindings.empty()) {
    state = ready;
    
    if(controlStream != 0) {
      Err::verbose(true, "No domains need to be bound - send ack");
      ackBindings();
    }
 } else {
    state = bindingStreams;

  }

  return OK;
}
Esempio n. 2
0
DysectAPI::DysectErrorCode Backend::prepareProbes(struct DysectBEContext_t* context, bool pending) {
  if(!pending) {
    assert(context);
    assert(context->walkerSet);

    walkerSet = context->walkerSet;

    Domain::setBEContext(context);

    DysectAPI::DaemonHostname = context->hostname;
  }

  vector<Probe*> roots, removePending;
  if(pending)
    roots = ProbeTree::getPendingRoots();
  else
    roots = ProbeTree::getRoots();

  for(int i = 0; i < roots.size(); i++) {
    Probe* probe = roots[i];

    // Prepare all streams ie. ensure all domain ids and tags are created
    // for stream -> domain binding
    if(probe->prepareStream(recursive) != OK) {
      DYSECTWARN(Error, "Error occured while preparing streams");
      if(!pending)
        ProbeTree::addPendingRoot(probe);
      continue;
    }

    if(probe->prepareEvent(recursive) != OK) {
      if(!pending) {
        DYSECTLOG(Error, "Error occured while preparing events, adding to pending events");
        ProbeTree::addPendingRoot(probe);
      }
      continue;
      DYSECTWARN(Error, "Error occured while preparing events");
    }

    DYSECTVERBOSE(true, "Starting preparation of conditions");

    if(probe->prepareCondition(recursive) != OK) {
      DYSECTWARN(Error, "Error occured while preparing conditions");
      if(!pending)
        ProbeTree::addPendingRoot(probe);
      continue;
    }

    if(probe->prepareAction(recursive) != OK) {
      DYSECTWARN(Error, "Error occured while preparing actions");
      if(!pending)
        ProbeTree::addPendingRoot(probe);
      continue;
    }

    if(pending) {
      DYSECTVERBOSE(true, "Enabled pending probe %x", probe);
      removePending.push_back(probe);
    }
  }

  if(pending) {
    if(removePending.size() == 0)
      return OK;
    for(int i = 0; i < removePending.size(); i++)
      ProbeTree::removePendingRoot(removePending[i]);
  }

  // Add all domains to missing bindings
  map<tag_t, Domain*> domainMap = Domain::getDomainMap();
  map<tag_t, Domain*>::iterator domainIter = domainMap.begin();
  for(;domainIter != domainMap.end(); domainIter++) {
    tag_t domainId = domainIter->first;

    Domain* dom = domainIter->second;

    if(dom->anyTargetsAttached()) {
      DYSECTVERBOSE(true, "Missing domain: %x", domainId);
      missingBindings.insert(domainId);
    }
  }

  // List generated - wait for incoming frontend init packages

  if(missingBindings.empty()) {
    state = ready;

    if(controlStream != 0) {
      DYSECTVERBOSE(true, "No domains need to be bound - send ack");
      ackBindings();
    }
 } else {
    state = bindingStreams;

  }

  return OK;
}