Exemple #1
0
Vector getnodes(int onlyactive)
{
  ConcreteType nle = BuiltinInstCT(NODELISTELEMENTI);
  ConcreteType nl = BuiltinInstCT(NODELISTI);
  ConcreteType ct;
  Vector thenl;
  Object thenle;
  unsigned int stack[32];
  int i, howmany = 0;
  noderecord **nd;

  for (nd = &allnodes->p; *nd; nd = &(*nd)->p) {
    /* Ignore not yet filled out entries */
    if (ISNIL(OIDFetch((*nd)->node))) continue;
    if (onlyactive && ! (*nd)->up) continue;
    howmany ++;
  }
  anticipateGC(64 * 1024 + howmany * 6 * sizeof(u32));
  thenl = CreateVector(nl, howmany);
  for(i = 0, nd = &allnodes->p ; *nd ; nd = &(*nd)->p) {

    /* Ignore not yet filled out entries */
    if (ISNIL(OIDFetch((*nd)->node))) continue;
    if (onlyactive && ! (*nd)->up) continue;

    TRACE(rinvoke, 6, ("Node %d is on %s and up is %d", i,
		       NodeString((*nd)->srv), (*nd)->up));
    /* Build the node list element, it takes 4 arguments */
    /* The node */
    ct = BuiltinInstCT(NODEI); assert(ct);
    stack[0] = (unsigned int) OIDFetch((*nd)->node);
    stack[1] = (unsigned int) ct;
    /* Is it up? */
    ct = BuiltinInstCT(BOOLEANI); assert(ct);
    stack[4] = (unsigned int) (*nd)->up;
    stack[5] = (unsigned int) ct;
    /* incarnation Time */
    ct = BuiltinInstCT(TIMEI); assert(ct);
    stack[2] = (unsigned int) OIDFetch((*nd)->inctm);
    stack[3] = (unsigned int) ct;
    /* lnn */
    stack[6] = (*nd)->node.port << 16 | (*nd)->node.epoch;
    stack[7] = (unsigned int) intct;
    thenle = CreateObjectFromOutside(nle, (u32)stack);
    ((Object*)thenl->d.data)[i] = thenle;
    i ++;
  }
  inhibit_gc--;

  TRACE(rinvoke, 5, ("getactivenodes() got %d nodes", i));
  return thenl;
}
Exemple #2
0
void handleInvokeForwardRequest(RemoteOpHeader *h, Node srv, Stream str)
{
  ConcreteType ct;
  Object o;
  unsigned int answer;

  anticipateGC(64*1024 + 2 * StreamLength(str));
  TRACE(rinvoke, 3, ("InvokeForwardRequest received"));
  TRACE(rinvoke, 6, ("Checking for CT for incoming activation"));
  ct = (ConcreteType) doObjectRequest(srv, &h->targetct, ctct);
  assert(! ISNIL(ct));

  TRACE(rinvoke, 4, ("InvokeForwarded for object with ID %s", OIDString(h->target)));
  o = OIDFetch(h->target);
  assert(!ISNIL(o));
  if (RESDNT(o->flags)) {
    int more;
    State *state;
    TRACE(rinvoke, 4, ("The object is here, accepting activation"));
    ReadInt(&answer, str);
    more = memcmp(ReadStream(str, 4), "ACT!", 4);
    assert(!more);
    /* Suck out an activation record - argh! */
    TRACE(rinvoke, 6, ("Incoming activation record!!"));
    state = extractActivation(o, ct, str, srv);
    if (!ISNIL(answer)) {
#define sp state->sp
      PUSH(u32, answer);
      PUSH(ConcreteType, BuiltinInstCT(BOOLEANI));
    }
#undef sp
  } else {
    Node newsrv = getLocFromObj(o);
    TRACE(rinvoke, 4, ("Forwarding request to %s", NodeString(newsrv)));
    if (forwardMsg(newsrv, h, str) < 0) {
      Stream newstr;
      RewindStream(str);
      newstr = StealStream(str);
      findAndSendTo(h->target, newstr);
    }
  }
  TRACE(rinvoke, 4, ("Invoke forward request done"));
  inhibit_gc--;
}
Exemple #3
0
int MNodeConfigShow(

  mnode_t   *NS,
  int        VFlag,
  mpar_t    *P,
  mstring_t *String)

  {
  enum MNodeAttrEnum AList[] = {
    mnaMaxLoad,
    mnaPrioF,
    mnaPriority,
    mnaResOvercommitFactor,
    mnaResOvercommitThreshold,
    mnaNONE };

  mbitmap_t BM;

  int aindex;
  int nindex;

  mnode_t *N;

  if (String == NULL)
    {
    return(FAILURE);
    }

  String->clear();   /* Ensure we have a null/empty string */

  mstring_t NodeString(MMAX_LINE);
  mstring_t AttrLine(MMAX_LINE);

  if (VFlag == TRUE)
    bmset(&BM,mcmVerbose);

  for (nindex = 0;nindex < MSched.M[mxoNode];nindex++)
    {
    if (NS != NULL)
      {
      if (nindex != 0)
        break;

      N = NS;
      }
    else
      {
      N = MNode[nindex];
      }

    if ((N == NULL) || (N->Name[0] == '\0'))
      break;

    if (N->Name[0] == '\1')
      continue;

    NodeString.clear();

    MStringAppendF(&NodeString,"%s[%s] ",
      MCredCfgParm[mxoNode],
      N->Name);

    for (aindex = 0;AList[aindex] != mnaNONE;aindex++)
      {
      if ((MNodeAToString(
             N,
             AList[aindex],
             &AttrLine,
             &BM) == FAILURE) ||
          (AttrLine.empty()))
        {
        continue;
        }

      MStringAppendF(&NodeString," %s=%s",
        MNodeAttr[AList[aindex]],
        AttrLine.c_str());
      }    /* END for (aindex) */

    MStringAppendF(String,"%s\n",NodeString.c_str());
    }  /* END for (nindex) */

  return(SUCCESS);
  }  /* END MNodeConfigShow() */
Exemple #4
0
int rinvoke(State *state, Object obj, int fn)
{
  RemoteOpHeader h;
  u32 sb, sp = state->sp;
  int retc, argc;
  Node srv;
  Stream str; 
  ConcreteType ct;

  regRoot(obj);
  regRoot(state);
  anticipateGC(64 * 1024);  
  unregRoot();
  unregRoot();

  /* figure out where we're sending the invocation */
  ct = CODEPTR(obj->flags);
  assert(!RESDNT(obj->flags));
  srv = getLocFromObj(obj);

  /* figure out what object we're invoking on */
  h.target = OIDOf(obj);
  if (isNoOID(h.target)) {
    ConcreteType ct = CODEPTR(obj->flags);
    printf("It was a %.*s\n", ct->d.name->d.items, ct->d.name->d.data);
    return debug(state, "Invoked object with no oid");
  }
  assert(!isNoOID(h.target));
  h.targetct = OIDOf(ct);

  /* push the header information */
  h.kind = InvokeRequest;
  h.status = fn;
  h.option1 = retc = ct->d.opVector->d.data[fn]->d.nress;
  h.option2 = argc = ct->d.opVector->d.data[fn]->d.nargs;

  h.ss = OIDOf((Object)state);
  h.sslocation = myid;
  str = StartMsg(&h);
  state->nstoid = h.target;
  NewOID(&state->nsoid);
  TRACE(process, 5, ("Setting nsoid in state %#x to %s", state,
		     OIDString(state->nsoid)));
  WriteOID(&state->nsoid, str);
  sb = sp - 8 * argc;

  TRACE(rinvoke, 3, ("Invoking on %#x %s a %.*s [%d] -> [%d]", obj, 
		     OIDString(h.target),
		     ct->d.name->d.items,
		     ct->d.name->d.data, argc, retc));
  TRACE(rinvoke, 4, ("It is on node %s", NodeString(srv)));

  sendNVars(str, argc, (int *)sb, state->ep, state->et);
  state->sp = sb;
  inhibit_gc--;
  if (isLimbo(srv)) {
    findAndSendTo(h.target, str);
  } else {
    sendMsgTo(srv, str, h.target);
  }
  return 1;
}
Exemple #5
0
void handleInvokeRequest(RemoteOpHeader *h, Node srv, Stream str)
{
  Stream newstr;
  int argc = h->option2, retc = h->option1, fn = h->status, i;
  Object obj;
  ConcreteType ct = 0;
  RemoteOpHeader replyh;
  int *sp;
  State *state;

  anticipateGC(64 * 1024 + 2 * StreamLength(str));
  TRACE(rinvoke, 3, ("InvokeRequest received"));
  /* figure out who we're invoking on */
  obj = OIDFetch(h->target);

  if (!ISNIL(obj)) {
    ct = CODEPTR(obj->flags);
    TRACE(rinvoke, 4, ("Target is a %.*s, operation name is %.*s[%d]",
		       ct->d.name->d.items, ct->d.name->d.data, 
		       ct->d.opVector->d.data[fn]->d.name->d.items,
		       ct->d.opVector->d.data[fn]->d.name->d.data, argc));
  } else {
    TRACE(rinvoke, 1, ("Invoking %s op %d [%d] -> [%d]", OIDString(h->target),
		       fn, argc, retc));
  }

  if (ISNIL(obj)) {
    /*
     * Invoke came here, but we don't know anything about this object.
     * First find it, then send it the message.
     */
    TRACE(rinvoke, 1, ("Trying to find the object and send it the message"));
    ct = (ConcreteType)doObjectRequest(replyh.sslocation, &h->targetct, ctct);
    obj = createStub(ct, getNodeRecordFromSrv(replyh.sslocation), h->target);

    RewindStream(str);
    newstr = StealStream(str);
    findAndSendTo(h->target, newstr);
  } else if (!RESDNT(obj->flags)) {
    Node newsrv = getLocFromObj(obj);
    /* Invoke came here, but the object is elsewhere */
    /* First check to see if we think the object is where this invoke
       came from */
    if (SameNode(srv, newsrv) || SameNode(myid, newsrv) || SameNode(limbo, newsrv)) {
      TRACE(rinvoke, 1, ("Have stub, but points back.  Forwarding to limbo"));
      RewindStream(str);
      newstr = StealStream(str);
      findAndSendTo(h->target, newstr);
    } else {
      TRACE(rinvoke, 1, ("Forwarding invoke to %s", NodeString(newsrv)));
      if (forwardMsg(newsrv, h, str) < 0) {
	RewindStream(str);
	newstr = StealStream(str);
	findAndSendTo(h->target, newstr);
      }
    }
  } else if (fakeUnavailable && ((random() % 100) < fakeUnavailable)) {
    newstr = StealStream(str);
    sendUnavailableReply(newstr);
  } else {
    OID oid;
    state = newState(obj, ct);
    OIDRemoveAny((Object)state);
    ReadOID(&oid, str);
    OIDInsert(oid, (Object) state);
    for (sp = (int *)state->sb, i = 0 ; i < 2 * retc ; i++) *sp++ = JNIL;
    extractNVars(str, argc, sp, &state->ep, &state->et, srv);
    sp += argc * 2;
    TRACE(rinvoke, 4, ("Doing upcall on a %.*s",
		       CODEPTR(obj->flags)->d.name->d.items, 
		       CODEPTR(obj->flags)->d.name->d.data));
    state->sp = (u32)sp;
    pushBottomAR(state);

    /* set up the interpreter state */
    state->pc = (u32) ct->d.opVector->d.data[fn]->d.code->d.data;
    dependsOn(state, stateFetch(h->ss, h->sslocation), retc);
    makeReady(state);
  }
  inhibit_gc--;
}