Package java.util

Examples of java.util.Set


      Properties expProps = new Properties();
      BufferedInputStream bi = new BufferedInputStream(new FileInputStream(propsFile));
      expProps.load(bi);
      bi.close();
      bi = null;
      Set keys = expProps.keySet();
      Iterator keysI = keys.iterator();
      while (keysI.hasNext()) {
        String key = (String)keysI.next();
        if (!key.endsWith("Policy")) {
          // See if this key is in the Explorer props
          String existingVal = ExplorerDefaults.get(key, "");
View Full Code Here


            if (iVariable.equals(anotherVariable)) return null;
            return ((Swapable)iVariable).findSwap(anotherVariable);
        } else {
            Value value = (Value)object;
            if (value.equals(iVariable.getAssignment())) return null;
            Set conflicts = model.conflictValues(value);
            double eval = iValueWeight * value.toDouble();
            if (iVariable.getAssignment()!=null)
                eval -= iValueWeight * iVariable.getAssignment().toDouble();
            else
                eval -= iConflictWeight;
View Full Code Here

        Assignment rmAss = allAssignments.remove(index);
        assert rmAss != null : index + " Cannot remove assignment:" + ass;
        assert index >= 0 : index + " Cannot remove assignment:" + ass;

        float[] oldColumn = origMatrix.getColumn(index);
        Set oldAvailableLocs = FastSet.newInstance();
        oldAvailableLocs.addAll(availableLocations);

        EventOrderConstraint oc = ass.getEvent().getConstraint(EventOrderConstraint.class);
        if (oc != null) {
            for (Event ev : oc.getFollows()) {
                Integer n = orderContainer.remove(ev);
View Full Code Here

        Model model = solution.getModel();
        boolean canConflict = model.nrAssignedVariables()!=0;
        Variable variable = (Variable)ToolBox.random(model.variables());
        Value value = (Value)ToolBox.random(variable.values());
        if (value.equals(variable.getAssignment())) return null;
        Set conflicts = model.conflictValues(value);
        double eval = iValueWeight * value.toDouble();
        if (variable.getAssignment()!=null)
            eval -= iValueWeight * variable.getAssignment().toDouble();
        else
            eval -= iConflictWeight;
View Full Code Here

  @Test
  public void testValidate() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    Date sqlDate = Date.valueOf("1999-12-12");
    simpleForm.setDateValue("1999-12-12");
    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
View Full Code Here

  @Test
  public void testBadType() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    Date sqlDate = Date.valueOf("1999-12-12");
    simpleForm.setDateValue("1999-12-12");
    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
View Full Code Here

  @Test
  public void testValidateNull() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
View Full Code Here

  @Test
  public void testConversionFailure() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
View Full Code Here

    protected void shutdown() {}

    public void run() {
      Message msg = null;
      Set servers = new HashSet();
      try {
        try {
          nos = new NetworkOutputStream();
        } catch (IOException exc) {
          logmon.log(BasicLevel.FATAL, getName() + ", cannot start.");
          return;
        }

        while (running) {
          canStop = true;
          try {
            if (this.logmon.isLoggable(BasicLevel.DEBUG))
              this.logmon.log(BasicLevel.DEBUG, this.getName() + ", waiting message");
            msg = qout.get(WDActivationPeriod);
          } catch (InterruptedException exc) {
            if (this.logmon.isLoggable(BasicLevel.DEBUG))
              this.logmon.log(BasicLevel.DEBUG, this.getName() + ", interrupted");
            continue;
          }
          canStop = false;
          if (! running) break;

          if (msg != null) {
            sendList.addMessage(msg);
            qout.pop();
          }
          long currentTimeMillis = System.currentTimeMillis();
          ServerDesc server = null;

          Iterator iterator = sendList.toSendIterator();

          while (iterator.hasNext()) {
            msg = (Message) iterator.next();
            short msgto = msg.getDest();

            if (this.logmon.isLoggable(BasicLevel.DEBUG))
              this.logmon.log(BasicLevel.DEBUG,
                              this.getName() +
                              ", check msg#" + msg.getStamp() +
                              " from " + msg.from +
                              " to " + msg.to);

            if (msg.not.expiration > 0L && msg.not.expiration < currentTimeMillis) {
             
              // Remove the message.
              AgentServer.getTransaction().begin();

              if (msg.not.deadNotificationAgentId != null) {
                if (logmon.isLoggable(BasicLevel.DEBUG)) {
                  logmon.log(BasicLevel.DEBUG, getName() + ": forward expired notification " + msg.from
                      + ", " + msg.not + " to " + msg.not.deadNotificationAgentId);
                }
                ExpiredNot expiredNot = new ExpiredNot(msg.not, msg.from, msg.to);
                Channel.post(Message.alloc(AgentId.localId, msg.not.deadNotificationAgentId, expiredNot));
                Channel.validate();
              } else {
                if (logmon.isLoggable(BasicLevel.DEBUG)) {
                  logmon.log(BasicLevel.DEBUG, getName() + ": removes expired notification " + msg.from + ", "
                      + msg.not);
                }
              }

              // Deletes the processed notification
              iterator.remove();
    // AF: A reprendre.
//               // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
              continue;
            }

            try {
              server = AgentServer.getServerDesc(msgto);
            } catch (UnknownServerException exc) {
              this.logmon.log(BasicLevel.ERROR,
                              this.getName() + ", can't send message: " + msg,
                              exc);
              // Remove the message, may be we have to post an error
              // notification to sender.
              AgentServer.getTransaction().begin();
              // Deletes the processed notification
              iterator.remove();
    // AF: A reprendre.
//              // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
              continue;
            }

            if (servers.contains(server)) {
              // The server has already been tested during this round
              continue;
            }

            this.logmon.log(BasicLevel.DEBUG,
                            this.getName() + server.active + ',' +
                            server.retry + ',' +
                            server.last + ',' +
                            currentTimeMillis);

            if ((server.active) ||
                ((server.retry < WDNbRetryLevel1) &&
                 ((server.last + WDRetryPeriod1) < currentTimeMillis)) ||
                ((server.retry < WDNbRetryLevel2) &&
                 ((server.last + WDRetryPeriod2) < currentTimeMillis)) ||
                ((server.last + WDRetryPeriod3) < currentTimeMillis)) {
              try {
                if (this.logmon.isLoggable(BasicLevel.DEBUG))
                  this.logmon.log(BasicLevel.DEBUG,
                                  this.getName() +
                                  ", send msg#" + msg.getStamp());

                // Open the connection.
                Socket socket = createSocket(server);
                // The connection is ok, reset active and retry flags.
                server.active = true;
                server.retry = 0;
                server.last = currentTimeMillis;

                setSocketOption(socket);

                send(socket, msg, currentTimeMillis);
              } catch (SocketException exc) {
                if (this.logmon.isLoggable(BasicLevel.WARN))
                  this.logmon.log(BasicLevel.WARN,
                                  this.getName() + ", let msg in watchdog list",
                                  exc);
                server.active = false;
                server.retry++;
                server.last = currentTimeMillis;
               
                // Do not send following messages to this server
                servers.add(server);
                //  There is a connection problem, let the message in the
                // waiting list.
                continue;
              } catch (Exception exc) {
                this.logmon.log(BasicLevel.ERROR,
                                this.getName() + ", error", exc);
              }

              AgentServer.getTransaction().begin();
              //  Deletes the processed notification
              iterator.remove();
// AF (TODO): To remove ?
//               // send ack in JGroups to delete msg
//               if (jgroups != null)
//                 jgroups.send(new JGroupsAckMsg(msg));
              msg.delete();
              msg.free();
              AgentServer.getTransaction().commit(true);
            } else {
              // Do not send following messages to this server
              servers.add(server);
            }
          }
          servers.clear();
        }
      } catch (Exception exc) {
        this.logmon.log(BasicLevel.FATAL,
                        this.getName() + ", unrecoverable exception", exc);
        //  There is an unrecoverable exception during the transaction
View Full Code Here

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG, "MonitoringHelper.getJMXValues() -> " + element.mbean);
     
      try {
        Set mBeans = MXWrapper.queryNames(element.mbean);
        if (mBeans != null) {
          for (Iterator iterator = mBeans.iterator(); iterator.hasNext();) {
            String mBean = (String) iterator.next();
           
            for (int j=0; j<element.attributes.length; j++) {
              try {
                if (element.attributes[j].equals("*")) {
View Full Code Here

TOP

Related Classes of java.util.Set

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.