Exemplo n.º 1
0
 public void save(Chunk chunk) {
   ChunkPosition pos = chunk.getPosition();
   CompressedChunk c = chunks.get(pos);
   if (c == null) {
     c = new CompressedChunk(pos);
     chunks.put(pos, c);
     c.setVersion(~chunk.getVersion());
   }
   if (c.getVersion() != chunk.getVersion()) {
     if (c.getData() != null) {
       approxSize.addAndGet(-c.getData().length);
     }
     long start = TimeStatistics.TIME_STATISTICS.start();
     //            ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
     //            DataOutputStream dataOut = new DataOutputStream(byteOut);
     //            compressor.compress(dataOut, chunk.getDataXZY());
     try {
       c.setData(DeflaterWrapper.compress(chunk.getDataXZY()));
       //                c.setData(DeflaterWrapper.compress(byteOut.toByteArray()));
     } catch (IOException ex) {
       throw new RuntimeException(ex);
     }
     c.setVersion(chunk.getVersion());
     TimeStatistics.TIME_STATISTICS.end(start, "save");
     approxSize.addAndGet(-c.getData().length);
     if (chunks.size() % 1000 == 0) {
       System.out.println(
           Util.humanReadableByteCount(approxSize.get())
               + ", "
               + Util.humanReadableByteCount(approxSize.get() / chunks.size())
               + "/chunk");
     }
   }
 }
 public String[] listConsumers() {
   synchronized (lock) {
     String[] ret = new String[consumers.size()];
     Iterator<Map.Entry<String, Integer>> i = consumers.entrySet().iterator();
     for (int x = 0; x < consumers.size(); x++) {
       Map.Entry<String, Integer> pair = (Map.Entry<String, Integer>) i.next();
       ret[x] = pair.getKey();
     }
     return ret;
   }
 }
Exemplo n.º 3
0
  /** Function for refreshing the status area after editing status items */
  public void repaintToolbar() {

    // Lets start by adding all the notifications
    for (Entry<String, JLabel> entry : statusItems.entrySet()) {
      JLabel statusItem = entry.getValue();
      statusItem.setFont(new Font("Arial", Font.PLAIN, 11));
      statusItem.setForeground(new Color(237, 237, 237));
      statusPanel.add(statusItem);
    }

    // Then add all the highlighted vessel info
    highlightPanel.removeAll();
    JLabel highlightTitle = new JLabel(" Highlighted Vessel");
    highlightTitle.setFont(new Font("Arial", Font.BOLD, 11));
    highlightTitle.setForeground(new Color(237, 237, 237));
    if (highlightItems.size() > 0) {
      highlightTitle.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(65, 65, 65)));
      highlightPanel.add(highlightTitle);
    }
    for (Entry<String, JLabel> entry : highlightItems.entrySet()) {
      JLabel highlightItem = entry.getValue();
      highlightItem.setFont(new Font("Arial", Font.PLAIN, 11));
      highlightItem.setForeground(new Color(237, 237, 237));
      highlightPanel.add(highlightItem);
    }

    // Then calculate the size of the status bar according to the number of
    // status items
    width = statusItemWidth;
    int innerHeight = statusItems.size() * statusItemHeight;
    // Expanding width highlight size.
    int innerHeight2 = highlightItems.size() * statusItemHeight;
    if (highlightItems.size() > 0) {
      innerHeight2 += statusItemHeight;
    }

    // find height of the two areas plus 7 for separator
    height = innerHeight + innerHeight2 + 7;

    if (!locked) {
      height = innerHeight + innerHeight2 + moveHandlerHeight;
    }

    // And finally set the size and repaint it
    statusPanel.setSize(width, innerHeight - statusPanelOffset);
    statusPanel.setPreferredSize(new Dimension(width, innerHeight - statusPanelOffset));
    // Also for highlight panel
    highlightPanel.setSize(width, innerHeight2 - statusPanelOffset);
    highlightPanel.setPreferredSize(new Dimension(width, innerHeight2 - statusPanelOffset));
    this.setSize(width, height);
    this.revalidate();
    this.repaint();
  }
 /**
  * Test onAddChatWindow
  *
  * @throws IllegalArgumentException
  * @throws NoSuchFieldException
  * @throws IllegalAccessException
  */
 public void testCase02_onAddChatWindow()
     throws IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
   Logger.d(TAG, "testCase02_onAddChatWindow");
   ConcurrentHashMap<IChatWindow, IChatWindowMessage> chatWindowMap = getChatWindowMapFiled();
   chatWindowMap.clear();
   mReceivedChatMessage.onAddChatWindow(null);
   assertTrue(chatWindowMap.size() == 0);
   mOneOneWindow.mShouldAddSentMessage = false;
   mReceivedChatMessage.onAddChatWindow(mOneOneWindow);
   assertTrue(chatWindowMap.size() == 0);
   mOneOneWindow.mShouldAddSentMessage = true;
   mReceivedChatMessage.onAddChatWindow(mOneOneWindow);
   assertTrue(chatWindowMap.containsKey(mOneOneWindow));
   chatWindowMap.clear();
 }
Exemplo n.º 5
0
  /*
   * (non-Javadoc)
   *
   * @see com.intel.stl.ui.console.IConsoleEventListener#removeConsole()
   */
  @Override
  public synchronized void removeConsole(int id) {

    // This method is called on clean up and when an individual
    // console tab is closed and requires that the console id
    // to be supplied
    if (consoleControllers.size() > 0) {

      // Find the session for the console controller specified by id
      ConsoleTerminalController currentConsole = consoleControllers.get(id);

      if (currentConsole != null) {
        Session currentSession = currentConsole.getSession();
        decrementSessionUsers(currentSession);
        displayMaxConsoles(false);

        // Shutdown console's processing thread.
        currentConsole.shutDownConsole();
      } // if
    } // if

    if (consoleNum > 0) {
      consoleNum--;
    }
  }
 /*
  * returns the channel previously associated with agentId, or null if any.
  */
 public static ChannelHandlerContext add(String agentId, ChannelHandlerContext channel) {
   ChannelHandlerContext previous = remoteChannels.put(agentId, channel);
   log.info(
       "Adding new ChannelHandlerContext to InboundRemoteChannels. Current size: "
           + remoteChannels.size());
   return previous;
 }
 /**
  * Gets a {@link JSONObject} containing the post data supplied with the current request as
  * key-value pairs appended with the instrumentation data.
  *
  * <p>* @param instrumentationData {@link ConcurrentHashMap} with instrumentation values
  *
  * @return A {@link JSONObject} containing the post data supplied with the current request as
  *     key-value pairs and the instrumentation meta data.
  */
 public JSONObject getPostWithInstrumentationValues(
     ConcurrentHashMap<String, String> instrumentationData) {
   JSONObject extendedPost = new JSONObject();
   try {
     // Add original parameters
     if (params_ != null) {
       JSONObject originalParams = new JSONObject(params_.toString());
       Iterator<String> keys = originalParams.keys();
       while (keys.hasNext()) {
         String key = keys.next();
         extendedPost.put(key, originalParams.get(key));
       }
     }
     // Append instrumentation metadata
     if (instrumentationData.size() > 0) {
       JSONObject instrObj = new JSONObject();
       Set<String> keys = instrumentationData.keySet();
       try {
         for (String key : keys) {
           instrObj.put(key, instrumentationData.get(key));
           instrumentationData.remove(key);
         }
         extendedPost.put(Defines.Jsonkey.Branch_Instrumentation.getKey(), instrObj);
       } catch (JSONException ignore) {
       }
     }
   } catch (JSONException ignore) {
   } catch (ConcurrentModificationException ex) {
     extendedPost = params_;
   }
   return extendedPost;
 }
Exemplo n.º 8
0
  @Override
  public boolean endSubscribtionToChannel(String exchangeName) {
    Channel channel = subscribedChannels.get(exchangeName);
    if (channel != null) {
      try {
        String queueName = channel.queueDeclare().getQueue();
        channel.queueUnbind(queueName, exchangeName, "");
        //				channel.basicConsume(queueName, arg1)

        //				channel.close(0,exchangeName);
        subscribedChannels.remove(exchangeName);
        channel = null;
        Log.i(
            LOGTAG,
            "subscribed to "
                + subscribedChannels.size()
                + " Channels"
                + "\n"
                + "ended subscribtion to : "
                + exchangeName);
        return true;
      } catch (AlreadyClosedException e) {
        Log.e(LOGTAG, "endSubcribtionToChannel: " + e.toString());
        subscribedChannels.remove(exchangeName);
      } catch (IOException e) {
        Log.e(LOGTAG, "endSubcribtionToChannel: " + e.toString());
      } catch (ShutdownSignalException e) {
        Log.e(LOGTAG, "endSubcribtionToChannel: " + e.toString());
      }
    }
    return false;
  }
Exemplo n.º 9
0
  @Override
  public boolean subscribeToChannel(String exchangeName, String type) {
    if (!connected) {
      return false;
    }
    try {
      // we create a new channel
      Channel channel = connection.createChannel();
      channel.exchangeDeclare(exchangeName, type);
      String queueName = channel.queueDeclare().getQueue();
      channel.queueBind(queueName, exchangeName, "");

      // we define what happens if we recieve a new Message
      channel.basicConsume(queueName, new RabbitMQConsumer(channel, service));
      subscribedChannels.putIfAbsent(exchangeName, channel);
      Log.i(
          LOGTAG,
          "subscribed to "
              + subscribedChannels.size()
              + " Channels"
              + "\n"
              + "started subscribtion to : "
              + exchangeName);
      return true;
    } catch (Exception e) {
      Log.e(LOGTAG, "Connection Problem at subscribeToChannel(): " + e.toString());
    }
    return false;
  }
Exemplo n.º 10
0
 // TODO
 @GET
 @Path("/jobQueue/{jobID}")
 // @Produces(MediaType.TEXT_XML)
 public Response checkJobQueue(@PathParam("jobID") String jobID) {
   // does job exist?
   System.out.println("[checkJobQueue] queue length = " + jobqueue.size());
   System.out.println("[checkJobQueue] jobID = " + jobID);
   if (jobqueue.containsKey(UUID.fromString(jobID))) {
     System.out.println("Found job ID");
     // if job is not finished yet return 200
     if (jobqueue.get(UUID.fromString(jobID)).getStatus() == SFPGenJob.PROCESSING)
       return Response.status(Status.OK)
           .entity("Still processing - please check back later.")
           .build();
     // if job is finished and SFP has been created
     else {
       // return path to SFP resource
       URI sfp_uri;
       try {
         sfp_uri = new URI("SFP/sfplist/" + jobID);
         // update jobQueue
         SFPGenJob currjob = jobqueue.get(UUID.fromString(jobID));
         currjob.updateStatus(SFPGenJob.GONE);
         jobqueue.put(UUID.fromString(jobID), currjob);
         return Response.status(Status.SEE_OTHER).location(sfp_uri).build();
       } catch (URISyntaxException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
       return Response.serverError().build();
     }
   } else return Response.serverError().entity("No such job ID").build();
 }
Exemplo n.º 11
0
  public static int getStamp(ExternalStampBI version) {
    assert version.getStatus() != null : "Status is null; was it initialized?";
    assert version.getTime() != 0 : "Time is 0; was it initialized?";
    assert version.getAuthorUuid() != null : "Author is null; was it initialized?";
    assert version.getModuleUuid() != null : "Module is null; was it initialized?";
    assert version.getPathUuid() != null : "Path is null; was it initialized?";

    if (version.getTime() == Long.MIN_VALUE) {
      return -1;
    }
    String stampKey =
        ""
            + version.getStatus()
            + version.getTime()
            + version.getAuthorUuid()
            + version.getModuleUuid()
            + version.getPathUuid();
    Integer stamp = stampCache.get(stampKey);
    if (stamp != null) {
      return stamp;
    }
    stamp =
        stampDb.getStamp(
            version.getStatus(),
            version.getTime(),
            uuidToNid(version.getAuthorUuid()),
            uuidToNid(version.getModuleUuid()),
            uuidToNid(version.getPathUuid()));

    if (stampCache.size() > 500) {
      stampCache = new ConcurrentHashMap<>();
    }
    stampCache.put(stampKey, stamp);
    return stamp;
  }
 /** {@inheritDoc} */
 public boolean remove(Broadcaster b, Object id) {
   boolean removed = store.remove(id, b);
   if (removed) {
     logger.debug("Removing Broadcaster {} factory size now {} ", id, store.size());
   }
   return removed;
 }
  /** {@inheritDoc} */
  @Override
  public Broadcaster lookup(Class<? extends Broadcaster> c, Object id, boolean createIfNull) {
    Broadcaster b = store.get(id);
    if (b != null && !c.isAssignableFrom(b.getClass())) {
      String msg =
          "Invalid lookup class " + c.getName() + ". Cached class is: " + b.getClass().getName();
      logger.debug(msg);
      throw new IllegalStateException(msg);
    }

    if ((b == null && createIfNull) || (b != null && b.isDestroyed())) {
      if (b != null) {
        logger.debug("Removing destroyed Broadcaster {}", b.getID());
        store.remove(b.getID(), b);
      }

      Broadcaster nb = store.get(id);
      if (nb == null) {
        nb = createBroadcaster(c, id);
        store.put(id, nb);
      }

      if (nb == null) {
        logger.debug("Added Broadcaster {} . Factory size: {}", id, store.size());
      }

      b = nb;
    }

    return b;
  }
Exemplo n.º 14
0
  /** This will be called periodically by the Transaction Manager */
  public XAResource[] getXAResources() {
    try {
      checkFailures();

      HornetQXAResourceWrapper[] resourceArray = new HornetQXAResourceWrapper[recoveries.size()];
      resourceArray = recoveries.values().toArray(resourceArray);

      if (HornetQJMSServerLogger.LOGGER.isDebugEnabled()) {
        HornetQJMSServerLogger.LOGGER.debug(
            "\n=======================================================================================");
        HornetQJMSServerLogger.LOGGER.debug("Returning the following list on getXAREsources:");
        for (Map.Entry<String, HornetQXAResourceWrapper> entry : recoveries.entrySet()) {
          HornetQJMSServerLogger.LOGGER.debug(
              "server-id=" + entry.getKey() + ", value=" + entry.getValue());
        }
        HornetQJMSServerLogger.LOGGER.debug(
            "=======================================================================================\n");
      }

      return resourceArray;
    } catch (Throwable e) {
      HornetQJMSServerLogger.LOGGER.warn(e.getMessage(), e);
      return new XAResource[] {};
    }
  }
Exemplo n.º 15
0
  // -------------------------------------------------------------------
  private static String reportNetworkState() {
    String str = "---\n";
    int totalNumOfPeers = peers.size();
    str += "total number of peers: " + totalNumOfPeers + "\n";

    return str;
  }
Exemplo n.º 16
0
 /**
  * TODO - implement a better algorithm
  *
  * @param queries
  */
 protected void removeOldest(ConcurrentHashMap<String, QueryStats> queries) {
   Iterator<String> it = queries.keySet().iterator();
   while (queries.size() > maxQueries && it.hasNext()) {
     String sql = it.next();
     it.remove();
     if (log.isDebugEnabled()) log.debug("Removing slow query, capacity reached:" + sql);
   }
 }
 /** {@inheritDoc} */
 public boolean canCacheConnection() {
   if (config.getMaxTotalConnections() != -1
       && trackedIdleConnections.size() >= config.getMaxTotalConnections()) {
     return false;
   } else {
     return true;
   }
 }
Exemplo n.º 18
0
 /*
  * (non-Javadoc)
  *
  * @see com.intel.stl.ui.console.IConsoleEventListener#getNumConsoles()
  */
 @Override
 public int getNumConsoles(boolean connectedOnly) {
   if (connectedOnly) {
     return consoleControllers.size();
   } else {
     return consoleNum;
   }
 }
Exemplo n.º 19
0
  /**
   * @param s
   * @throws java.io.IOException
   */
  private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
    s.defaultWriteObject();
    s.writeInt(map.size());

    for (Iterator<E> i = map.keySet().iterator(); i.hasNext(); ) {
      s.writeObject(i.next());
    }
  }
Exemplo n.º 20
0
 /** 重试发送失败的邮件 */
 private static void retrySendMail() {
   if (retryMap.size() == 0) {
     logger.info("邮件都发送成功,无需再重试!");
   } else {
     logger.info("邮件共有 [{}] 份需要重试,现在开始重试发送....", retryMap.size());
     while (retryMap.size() > 0) {
       for (MimeMessage mailMessage : retryMap.keySet()) {
         doSendMail(mailMessage);
         try {
           Thread.sleep(mailSleep * 1000L);
         } catch (InterruptedException e) {
         }
       }
     }
     logger.info("邮件重试发送完成!");
   }
 }
Exemplo n.º 21
0
    private boolean populateOutput(
        AtomicLong totalKeysProcessed,
        ConcurrentHashMap<String, BlobStatus> blobIdToStatusMap,
        int replicaCount,
        boolean includeAcceptableInconsistentBlobs) {
      logger.info("Total keys processed " + totalKeysProcessed.get());
      logger.info("\nTotal Blobs Found " + blobIdToStatusMap.size());
      long inconsistentBlobs = 0;
      long realInconsistentBlobs = 0;
      long acceptableInconsistentBlobs = 0;
      for (String blobId : blobIdToStatusMap.keySet()) {
        BlobStatus consistencyBlobResult = blobIdToStatusMap.get(blobId);
        // valid blobs : count of available replicas = total replica count or count of deleted
        // replicas = total replica count
        // acceptable inconsistent blobs : count of deleted + count of unavailable = total replica
        // count
        // rest are all inconsistent blobs
        boolean isValid =
            consistencyBlobResult.getAvailable().size() == replicaCount
                || consistencyBlobResult.getDeletedOrExpired().size() == replicaCount;
        if (!isValid) {
          inconsistentBlobs++;
          if ((consistencyBlobResult.getDeletedOrExpired().size()
                  + consistencyBlobResult.getUnavailableList().size()
              == replicaCount)) {
            if (includeAcceptableInconsistentBlobs) {
              logger.info(
                  "Partially deleted (acceptable inconsistency) blob "
                      + blobId
                      + " isDeletedOrExpired "
                      + consistencyBlobResult.getIsDeletedOrExpired()
                      + "\n"
                      + consistencyBlobResult);
            }
            acceptableInconsistentBlobs++;
          } else {
            realInconsistentBlobs++;
            logger.info(
                "Inconsistent Blob : "
                    + blobId
                    + " isDeletedOrExpired "
                    + consistencyBlobResult.getIsDeletedOrExpired()
                    + "\n"
                    + consistencyBlobResult);
          }
        }
      }
      logger.info("Total Inconsistent blobs count : " + inconsistentBlobs);
      if (includeAcceptableInconsistentBlobs) {
        logger.info("Acceptable Inconsistent blobs count : " + acceptableInconsistentBlobs);
      }
      logger.info("Real Inconsistent blobs count :" + realInconsistentBlobs);

      if (realInconsistentBlobs > 0) {
        return false;
      }
      return true;
    }
Exemplo n.º 22
0
 /** Update cache. */
 private static void updateFormatCache(Long key, String value) {
   if (value == null) {
     return;
   }
   if (formatCache.size() > CACHE_SIZE) {
     formatCache.clear();
   }
   formatCache.put(key, value);
 }
 public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
   if (Config.checkFunctionSwitch(invoker, invocation)) {
     logger.info("[{}] had [{}] breaker", localHost, breakCounterMap.size());
     return wrapBreakerInvoke(invoker, invocation);
   }
   Result result = invoker.invoke(invocation);
   toBeNormal(invoker, invocation);
   return result;
 }
Exemplo n.º 24
0
 /** Update cache. */
 private static void updateParseCache(String key, Long value) {
   if (value == null) {
     return;
   }
   if (parseCache.size() > CACHE_SIZE) {
     parseCache.clear();
   }
   parseCache.put(key, value);
 }
Exemplo n.º 25
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder(1024);

    sb.append("<admin-object");

    if (className != null)
      sb.append(" ")
          .append(CommonAdminObject.Attribute.CLASS_NAME)
          .append("=\"")
          .append(className)
          .append("\"");

    if (jndiName != null)
      sb.append(" ")
          .append(CommonAdminObject.Attribute.JNDI_NAME)
          .append("=\"")
          .append(jndiName)
          .append("\"");

    if (enabled != null)
      sb.append(" ")
          .append(CommonAdminObject.Attribute.ENABLED)
          .append("=\"")
          .append(enabled)
          .append("\"");

    if (useJavaContext != null) {
      sb.append(" ").append(CommonAdminObject.Attribute.USE_JAVA_CONTEXT);
      sb.append("=\"").append(useJavaContext).append("\"");
    }

    if (poolName != null)
      sb.append(" ")
          .append(CommonAdminObject.Attribute.POOL_NAME)
          .append("=\"")
          .append(poolName)
          .append("\"");

    sb.append(">");

    if (configProperties != null && configProperties.size() > 0) {
      Iterator<Map.Entry<String, String>> it = configProperties.entrySet().iterator();
      while (it.hasNext()) {
        Map.Entry<String, String> entry = it.next();

        sb.append("<").append(CommonAdminObject.Tag.CONFIG_PROPERTY);
        sb.append(" name=\"").append(entry.getKey()).append("\">");
        sb.append(entry.getValue());
        sb.append("</").append(CommonAdminObject.Tag.CONFIG_PROPERTY).append(">");
      }
    }

    sb.append("</admin-object>");

    return sb.toString();
  }
Exemplo n.º 26
0
 /**
  * Get a list of all {@link Album}s from this object.
  *
  * @return list of all {@link Album}s from this object.
  */
 public ArrayList<Album> getAlbums() {
   if (mAlbumsFetchedViaHatchet.size() > 0) {
     return new ArrayList<Album>(mAlbumsFetchedViaHatchet.values());
   }
   ArrayList<Album> albums = new ArrayList<Album>(mAlbums.values());
   Collections.sort(
       albums, new TomahawkListItemComparator(TomahawkListItemComparator.COMPARE_ALPHA));
   return albums;
 }
  public int size() {
    if (k1_k2V_map.size() == 0) return 0;

    int result = 0;
    for (ConcurrentHashMap<K2, V> k2V_map : k1_k2V_map.values()) {
      result += k2V_map.size();
    }
    return result;
  }
 private void checkTopic2(
     final ConcurrentHashMap<String, ConcurrentHashMap<Partition, TopicPartitionRegInfo>>
         topicRegistry) {
   final ConcurrentHashMap<Partition, TopicPartitionRegInfo> partMap2 =
       topicRegistry.get("topic2");
   assertNotNull(partMap2);
   assertEquals(1, partMap2.size());
   assertTrue(partMap2.containsKey(new Partition("0-0")));
   assertFalse(partMap2.containsKey(new Partition("1-0")));
 }
  @Test
  public void testSetId() {
    ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>();
    OperationContext context = new OperationContext(map);
    context.setId("mock");

    assertEquals(context.getId(), "mock");
    assertEquals(map.size(), 1);
    assertEquals(map.get(ContextTagKeys.getKeys().getOperationId()), "mock");
  }
Exemplo n.º 30
0
  public static void main(String[] args) {
    ConcurrentHashMap<String, Integer> vehicles = new ConcurrentHashMap();

    /* Add some vehicles. */
    vehicles.put("BMW", 5);
    vehicles.put("Mercedes", 3);
    vehicles.put("Audi", 4);
    vehicles.put("Ford", 10);

    System.out.println("Total vehicles: " + vehicles.size());

    /* Iterate over all vehicles, using the keySet method. */
    for (String key : vehicles.keySet()) System.out.println(key + " - " + vehicles.get(key));

    System.out.println("-----------------------------------");

    String searchKey = "Audi";
    if (vehicles.containsKey(searchKey))
      System.out.println("Found total '" + vehicles.get(searchKey) + "' " + searchKey + " cars!\n");

    Enumeration elems = vehicles.elements();
    while (elems.hasMoreElements()) System.out.println(elems.nextElement());

    System.out.println("-----------------------------------");

    Integer val = vehicles.putIfAbsent("Audi", 9);
    if (val != null) System.out.println("Audi was found in the map and its value was updated!");

    val = vehicles.putIfAbsent("Nissan", 9);
    if (val == null) System.out.println("Nissan wasn't found in map, thus a new pair was created!");

    System.out.println("-----------------------------------");

    // The next statements throw a NullPointerException, if uncommented.
    // vehicles.put("Nissan", null);
    // vehicles.put(null, 6);

    /* Clear all values. */
    vehicles.clear();

    /* Equals to zero. */
    System.out.println("After clear operation, size: " + vehicles.size());
  }