Examples of MapWritable


Examples of org.apache.hadoop.io.MapWritable

          scannerId = server.openScanner(t.getRegionInfo().getRegionName(),
              COLUMN_FAMILY_ARRAY, EMPTY_START_ROW, System.currentTimeMillis(),
              null);

          while (true) {
            MapWritable values = server.next(scannerId);
            if (values == null || values.size() == 0) {
              break;
            }
            for (Map.Entry<Writable, Writable> e: values.entrySet()) {
              HStoreKey key = (HStoreKey) e.getKey();
              if (key.getColumn().equals(COL_REGIONINFO)) {
                HRegionInfo info = new HRegionInfo();
                info = (HRegionInfo) Writables.getWritable(
                    ((ImmutableBytesWritable) e.getValue()).get(), info);
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

        try {
          scannerId = server.openScanner(t.getRegionInfo().getRegionName(),
            COLUMN_FAMILY_ARRAY, tableName, System.currentTimeMillis(), null);

          while (true) {
            MapWritable values = server.next(scannerId);
            if (values == null || values.size() == 0) {
              if (servers.size() == 0) {
                // If we didn't find any servers then the table does not exist
                throw new TableNotFoundException("table '" + tableName +
                  "' does not exist in " + t);
              }

              // We found at least one server for the table and now we're done.
              if (LOG.isDebugEnabled()) {
                LOG.debug("Found " + servers.size() + " region(s) for " +
                  tableName + " at " + t);
              }
              break;
            }

            SortedMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
            for (Map.Entry<Writable, Writable> e: values.entrySet()) {
              HStoreKey key = (HStoreKey) e.getKey();
              results.put(key.getColumn(),
                  ((ImmutableBytesWritable) e.getValue()).get());
            }
           
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

   * @return map of colums to values
   * @throws IOException
   */
  public SortedMap<Text, byte[]> getRow(Text row) throws IOException {
    checkClosed();
    MapWritable value = null;
    for (int tries = 0; tries < numRetries; tries++) {
      HRegionLocation r = getRegionLocation(row);
      HRegionInterface server =
        connection.getHRegionConnection(r.getServerAddress());
     
      try {
        value = server.getRow(r.getRegionInfo().getRegionName(), row);
        break;
       
      } catch (IOException e) {
        if (e instanceof RemoteException) {
          e = RemoteExceptionHandler.decodeRemoteException((RemoteException) e);
        }
        if (tries == numRetries - 1) {
          // No more tries
          throw e;
        }
        if (LOG.isDebugEnabled()) {
          LOG.debug("reloading table servers because: " + e.getMessage());
        }
        tableServers = connection.reloadTableServers(tableName);
      }
      try {
        Thread.sleep(this.pause);
       
      } catch (InterruptedException x) {
        // continue
      }
    }
    SortedMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
    if (value != null && value.size() != 0) {
      for (Map.Entry<Writable, Writable> e: value.entrySet()) {
        HStoreKey key = (HStoreKey) e.getKey();
        results.put(key.getColumn(),
            ((ImmutableBytesWritable) e.getValue()).get());
      }
    }
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

    public boolean next(HStoreKey key, SortedMap<Text, byte[]> results) throws IOException {
      checkClosed();
      if (this.closed) {
        return false;
      }
      MapWritable values = null;
      do {
        values = this.server.next(this.scannerId);
      } while (values != null && values.size() == 0 && nextScanner());

      if (values != null && values.size() != 0) {
        for (Map.Entry<Writable, Writable> e: values.entrySet()) {
          HStoreKey k = (HStoreKey) e.getKey();
          key.setRow(k.getRow());
          key.setVersion(k.getTimestamp());
          key.setColumn(EMPTY_COLUMN);
          results.put(k.getColumn(),
              ((ImmutableBytesWritable) e.getValue()).get());
        }
      }
      return values == null ? false : values.size() != 0;
    }
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

      long scannerId = -1L;
      try {
        scannerId =
          server.openScanner(firstMetaServer.getRegionInfo().getRegionName(),
            COL_REGIONINFO_ARRAY, tableName, System.currentTimeMillis(), null);
        MapWritable values = server.next(scannerId);
        if (values == null || values.size() == 0) {
          break;
        }
        boolean found = false;
        for (Map.Entry<Writable, Writable> e: values.entrySet()) {
          HStoreKey key = (HStoreKey) e.getKey();
          if (key.getColumn().equals(COL_REGIONINFO)) {
            info = (HRegionInfo) Writables.getWritable(
                  ((ImmutableBytesWritable) e.getValue()).get(), info);
           
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

          server.openScanner(firstMetaServer.getRegionInfo().getRegionName(),
            COL_REGIONINFO_ARRAY, tableName, System.currentTimeMillis(), null);
        boolean isenabled = false;
       
        while (true) {
          MapWritable values = server.next(scannerId);
          if (values == null || values.size() == 0) {
            if (valuesfound == 0) {
              throw new NoSuchElementException(
                  "table " + tableName + " not found");
            }
            break;
          }
          valuesfound += 1;
          for (Map.Entry<Writable, Writable> e: values.entrySet()) {
            HStoreKey key = (HStoreKey) e.getKey();
            if (key.getColumn().equals(COL_REGIONINFO)) {
              info = (HRegionInfo) Writables.getWritable(
                    ((ImmutableBytesWritable) e.getValue()).get(), info);
           
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

          server.openScanner(firstMetaServer.getRegionInfo().getRegionName(),
            COL_REGIONINFO_ARRAY, tableName, System.currentTimeMillis(), null);
       
        boolean disabled = false;
        while (true) {
          MapWritable values = server.next(scannerId);
          if (values == null || values.size() == 0) {
            if (valuesfound == 0) {
              throw new NoSuchElementException("table " + tableName + " not found");
            }
            break;
          }
          valuesfound += 1;
          for (Map.Entry<Writable, Writable> e: values.entrySet()) {
            HStoreKey key = (HStoreKey) e.getKey();
            if (key.getColumn().equals(COL_REGIONINFO)) {
              info = (HRegionInfo) Writables.getWritable(
                    ((ImmutableBytesWritable) e.getValue()).get(), info);
           
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

  public void reduce(Text key, @SuppressWarnings("unchecked") Iterator values,
      TableOutputCollector output,
      @SuppressWarnings("unused") Reporter reporter) throws IOException {
   
    while(values.hasNext()) {
      MapWritable r = (MapWritable)values.next();
      output.collect(key, r);
    }
  }
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

     *
     * @see org.apache.hadoop.mapred.RecordReader#createValue()
     */
    @SuppressWarnings("unchecked")
    public MapWritable createValue() {
      return new MapWritable();
    }
View Full Code Here

Examples of org.apache.hadoop.io.MapWritable

   */
  private MapWritable reportForDuty() {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Telling master we are up");
    }
    MapWritable result = null;
    long lastMsg = 0;
    while(!stopRequested.get()) {
      try {
        this.requestCount.set(0);
        this.serverInfo.setLoad(new HServerLoad(0, onlineRegions.size()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.