HBASE-819 Remove DOS-style ^M carriage returns from all code where found (Jonathan Gray via Jim Kellerman)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@685009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jim Kellerman 2008-08-12 00:55:22 +00:00
parent 6cab23c4a0
commit 3d6b96aa48
7 changed files with 4506 additions and 4504 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,235 +1,235 @@
/** /**
* Copyright 2007 The Apache Software Foundation * Copyright 2007 The Apache Software Foundation
* *
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.hadoop.hbase; package org.apache.hadoop.hbase;
import org.apache.hadoop.hbase.ipc.HRegionInterface; import org.apache.hadoop.hbase.ipc.HRegionInterface;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
/** /**
* HConstants holds a bunch of HBase-related constants * HConstants holds a bunch of HBase-related constants
*/ */
public interface HConstants { public interface HConstants {
/** long constant for zero */ /** long constant for zero */
static final Long ZERO_L = Long.valueOf(0L); static final Long ZERO_L = Long.valueOf(0L);
static final String NINES = "99999999999999"; static final String NINES = "99999999999999";
static final String ZEROES = "00000000000000"; static final String ZEROES = "00000000000000";
// For migration // For migration
/** name of version file */ /** name of version file */
static final String VERSION_FILE_NAME = "hbase.version"; static final String VERSION_FILE_NAME = "hbase.version";
/** /**
* Current version of file system * Current version of file system
* Version 4 supports only one kind of bloom filter * Version 4 supports only one kind of bloom filter
*/ */
public static final String FILE_SYSTEM_VERSION = "4"; public static final String FILE_SYSTEM_VERSION = "4";
// Configuration parameters // Configuration parameters
// TODO: URL for hbase master like hdfs URLs with host and port. // TODO: URL for hbase master like hdfs URLs with host and port.
// Like jdbc URLs? URLs could be used to refer to table cells? // Like jdbc URLs? URLs could be used to refer to table cells?
// jdbc:mysql://[host][,failoverhost...][:port]/[database] // jdbc:mysql://[host][,failoverhost...][:port]/[database]
// jdbc:mysql://[host][,failoverhost...][:port]/[database][?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]... // jdbc:mysql://[host][,failoverhost...][:port]/[database][?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
// Key into HBaseConfiguration for the hbase.master address. // Key into HBaseConfiguration for the hbase.master address.
// TODO: Support 'local': i.e. default of all running in single // TODO: Support 'local': i.e. default of all running in single
// process. Same for regionserver. TODO: Is having HBase homed // process. Same for regionserver. TODO: Is having HBase homed
// on port 60k OK? // on port 60k OK?
/** Parameter name for master address */ /** Parameter name for master address */
static final String MASTER_ADDRESS = "hbase.master"; static final String MASTER_ADDRESS = "hbase.master";
/** default host address */ /** default host address */
static final String DEFAULT_HOST = "0.0.0.0"; static final String DEFAULT_HOST = "0.0.0.0";
/** default port that the master listens on */ /** default port that the master listens on */
static final int DEFAULT_MASTER_PORT = 60000; static final int DEFAULT_MASTER_PORT = 60000;
/** Default master address */ /** Default master address */
static final String DEFAULT_MASTER_ADDRESS = DEFAULT_HOST + ":" + static final String DEFAULT_MASTER_ADDRESS = DEFAULT_HOST + ":" +
DEFAULT_MASTER_PORT; DEFAULT_MASTER_PORT;
/** default port for master web api */ /** default port for master web api */
static final int DEFAULT_MASTER_INFOPORT = 60010; static final int DEFAULT_MASTER_INFOPORT = 60010;
/** Parameter name for hbase.regionserver address. */ /** Parameter name for hbase.regionserver address. */
static final String REGIONSERVER_ADDRESS = "hbase.regionserver"; static final String REGIONSERVER_ADDRESS = "hbase.regionserver";
/** Default region server address */ /** Default region server address */
static final String DEFAULT_REGIONSERVER_ADDRESS = DEFAULT_HOST + ":60020"; static final String DEFAULT_REGIONSERVER_ADDRESS = DEFAULT_HOST + ":60020";
/** default port for region server web api */ /** default port for region server web api */
static final int DEFAULT_REGIONSERVER_INFOPORT = 60030; static final int DEFAULT_REGIONSERVER_INFOPORT = 60030;
/** Parameter name for what region server interface to use. */ /** Parameter name for what region server interface to use. */
static final String REGION_SERVER_CLASS = "hbase.regionserver.class"; static final String REGION_SERVER_CLASS = "hbase.regionserver.class";
/** Parameter name for what region server implementation to use. */ /** Parameter name for what region server implementation to use. */
static final String REGION_SERVER_IMPL= "hbase.regionserver.impl"; static final String REGION_SERVER_IMPL= "hbase.regionserver.impl";
/** Default region server interface class name. */ /** Default region server interface class name. */
static final String DEFAULT_REGION_SERVER_CLASS = HRegionInterface.class.getName(); static final String DEFAULT_REGION_SERVER_CLASS = HRegionInterface.class.getName();
/** Parameter name for how often threads should wake up */ /** Parameter name for how often threads should wake up */
static final String THREAD_WAKE_FREQUENCY = "hbase.server.thread.wakefrequency"; static final String THREAD_WAKE_FREQUENCY = "hbase.server.thread.wakefrequency";
/** Parameter name for HBase instance root directory */ /** Parameter name for HBase instance root directory */
static final String HBASE_DIR = "hbase.rootdir"; static final String HBASE_DIR = "hbase.rootdir";
/** Used to construct the name of the log directory for a region server */ /** Used to construct the name of the log directory for a region server */
static final String HREGION_LOGDIR_NAME = "log"; static final String HREGION_LOGDIR_NAME = "log";
/** Name of old log file for reconstruction */ /** Name of old log file for reconstruction */
static final String HREGION_OLDLOGFILE_NAME = "oldlogfile.log"; static final String HREGION_OLDLOGFILE_NAME = "oldlogfile.log";
/** Default maximum file size */ /** Default maximum file size */
static final long DEFAULT_MAX_FILE_SIZE = 256 * 1024 * 1024; static final long DEFAULT_MAX_FILE_SIZE = 256 * 1024 * 1024;
/** Default size of a reservation block */ /** Default size of a reservation block */
static final int DEFAULT_SIZE_RESERVATION_BLOCK = 1024 * 1024 * 5; static final int DEFAULT_SIZE_RESERVATION_BLOCK = 1024 * 1024 * 5;
// Always store the location of the root table's HRegion. // Always store the location of the root table's HRegion.
// This HRegion is never split. // This HRegion is never split.
// region name = table + startkey + regionid. This is the row key. // region name = table + startkey + regionid. This is the row key.
// each row in the root and meta tables describes exactly 1 region // each row in the root and meta tables describes exactly 1 region
// Do we ever need to know all the information that we are storing? // Do we ever need to know all the information that we are storing?
// Note that the name of the root table starts with "-" and the name of the // Note that the name of the root table starts with "-" and the name of the
// meta table starts with "." Why? it's a trick. It turns out that when we // meta table starts with "." Why? it's a trick. It turns out that when we
// store region names in memory, we use a SortedMap. Since "-" sorts before // store region names in memory, we use a SortedMap. Since "-" sorts before
// "." (and since no other table name can start with either of these // "." (and since no other table name can start with either of these
// characters, the root region will always be the first entry in such a Map, // characters, the root region will always be the first entry in such a Map,
// followed by all the meta regions (which will be ordered by their starting // followed by all the meta regions (which will be ordered by their starting
// row key as well), followed by all user tables. So when the Master is // row key as well), followed by all user tables. So when the Master is
// choosing regions to assign, it will always choose the root region first, // choosing regions to assign, it will always choose the root region first,
// followed by the meta regions, followed by user regions. Since the root // followed by the meta regions, followed by user regions. Since the root
// and meta regions always need to be on-line, this ensures that they will // and meta regions always need to be on-line, this ensures that they will
// be the first to be reassigned if the server(s) they are being served by // be the first to be reassigned if the server(s) they are being served by
// should go down. // should go down.
/** The root table's name.*/ /** The root table's name.*/
static final byte [] ROOT_TABLE_NAME = Bytes.toBytes("-ROOT-"); static final byte [] ROOT_TABLE_NAME = Bytes.toBytes("-ROOT-");
/** The META table's name. */ /** The META table's name. */
static final byte [] META_TABLE_NAME = Bytes.toBytes(".META."); static final byte [] META_TABLE_NAME = Bytes.toBytes(".META.");
// Defines for the column names used in both ROOT and META HBase 'meta' tables. // Defines for the column names used in both ROOT and META HBase 'meta' tables.
/** The ROOT and META column family (string) */ /** The ROOT and META column family (string) */
static final String COLUMN_FAMILY_STR = "info:"; static final String COLUMN_FAMILY_STR = "info:";
/** The META historian column family (string) */ /** The META historian column family (string) */
static final String COLUMN_FAMILY_HISTORIAN_STR = "historian:"; static final String COLUMN_FAMILY_HISTORIAN_STR = "historian:";
/** The ROOT and META column family */ /** The ROOT and META column family */
static final byte [] COLUMN_FAMILY = Bytes.toBytes(COLUMN_FAMILY_STR); static final byte [] COLUMN_FAMILY = Bytes.toBytes(COLUMN_FAMILY_STR);
/** The META historian column family */ /** The META historian column family */
static final byte [] COLUMN_FAMILY_HISTORIAN = Bytes.toBytes(COLUMN_FAMILY_HISTORIAN_STR); static final byte [] COLUMN_FAMILY_HISTORIAN = Bytes.toBytes(COLUMN_FAMILY_HISTORIAN_STR);
/** Array of meta column names */ /** Array of meta column names */
static final byte[][] COLUMN_FAMILY_ARRAY = new byte[][] {COLUMN_FAMILY}; static final byte[][] COLUMN_FAMILY_ARRAY = new byte[][] {COLUMN_FAMILY};
/** ROOT/META column family member - contains HRegionInfo */ /** ROOT/META column family member - contains HRegionInfo */
static final byte [] COL_REGIONINFO = static final byte [] COL_REGIONINFO =
Bytes.toBytes(COLUMN_FAMILY_STR + "regioninfo"); Bytes.toBytes(COLUMN_FAMILY_STR + "regioninfo");
/** Array of column - contains HRegionInfo */ /** Array of column - contains HRegionInfo */
static final byte[][] COL_REGIONINFO_ARRAY = new byte[][] {COL_REGIONINFO}; static final byte[][] COL_REGIONINFO_ARRAY = new byte[][] {COL_REGIONINFO};
/** ROOT/META column family member - contains HServerAddress.toString() */ /** ROOT/META column family member - contains HServerAddress.toString() */
static final byte[] COL_SERVER = Bytes.toBytes(COLUMN_FAMILY_STR + "server"); static final byte[] COL_SERVER = Bytes.toBytes(COLUMN_FAMILY_STR + "server");
/** ROOT/META column family member - contains server start code (a long) */ /** ROOT/META column family member - contains server start code (a long) */
static final byte [] COL_STARTCODE = static final byte [] COL_STARTCODE =
Bytes.toBytes(COLUMN_FAMILY_STR + "serverstartcode"); Bytes.toBytes(COLUMN_FAMILY_STR + "serverstartcode");
/** the lower half of a split region */ /** the lower half of a split region */
static final byte [] COL_SPLITA = Bytes.toBytes(COLUMN_FAMILY_STR + "splitA"); static final byte [] COL_SPLITA = Bytes.toBytes(COLUMN_FAMILY_STR + "splitA");
/** the upper half of a split region */ /** the upper half of a split region */
static final byte [] COL_SPLITB = Bytes.toBytes(COLUMN_FAMILY_STR + "splitB"); static final byte [] COL_SPLITB = Bytes.toBytes(COLUMN_FAMILY_STR + "splitB");
/** All the columns in the catalog -ROOT- and .META. tables. /** All the columns in the catalog -ROOT- and .META. tables.
*/ */
static final byte[][] ALL_META_COLUMNS = {COL_REGIONINFO, COL_SERVER, static final byte[][] ALL_META_COLUMNS = {COL_REGIONINFO, COL_SERVER,
COL_STARTCODE, COL_SPLITA, COL_SPLITB}; COL_STARTCODE, COL_SPLITA, COL_SPLITB};
// Other constants // Other constants
/** /**
* An empty instance. * An empty instance.
*/ */
static final byte [] EMPTY_BYTE_ARRAY = new byte [0]; static final byte [] EMPTY_BYTE_ARRAY = new byte [0];
/** /**
* Used by scanners, etc when they want to start at the beginning of a region * Used by scanners, etc when they want to start at the beginning of a region
*/ */
static final byte [] EMPTY_START_ROW = EMPTY_BYTE_ARRAY; static final byte [] EMPTY_START_ROW = EMPTY_BYTE_ARRAY;
/** /**
* Last row in a table. * Last row in a table.
*/ */
static final byte [] EMPTY_END_ROW = EMPTY_START_ROW; static final byte [] EMPTY_END_ROW = EMPTY_START_ROW;
/** /**
* Used by scanners and others when they're trying to detect the end of a * Used by scanners and others when they're trying to detect the end of a
* table * table
*/ */
static final byte [] LAST_ROW = EMPTY_BYTE_ARRAY; static final byte [] LAST_ROW = EMPTY_BYTE_ARRAY;
/** When we encode strings, we always specify UTF8 encoding */ /** When we encode strings, we always specify UTF8 encoding */
static final String UTF8_ENCODING = "UTF-8"; static final String UTF8_ENCODING = "UTF-8";
/** /**
* Timestamp to use when we want to refer to the latest cell. * Timestamp to use when we want to refer to the latest cell.
* This is the timestamp sent by clients when no timestamp is specified on * This is the timestamp sent by clients when no timestamp is specified on
* commit. * commit.
*/ */
static final long LATEST_TIMESTAMP = Long.MAX_VALUE; static final long LATEST_TIMESTAMP = Long.MAX_VALUE;
/** /**
* Define for 'return-all-versions'. * Define for 'return-all-versions'.
*/ */
static final int ALL_VERSIONS = Integer.MAX_VALUE; static final int ALL_VERSIONS = Integer.MAX_VALUE;
/** /**
* Unlimited time-to-live. * Unlimited time-to-live.
*/ */
static final int FOREVER = -1; static final int FOREVER = -1;
public static final String HBASE_CLIENT_RETRIES_NUMBER_KEY = public static final String HBASE_CLIENT_RETRIES_NUMBER_KEY =
"hbase.client.retries.number"; "hbase.client.retries.number";
public static final int DEFAULT_CLIENT_RETRIES = 5; public static final int DEFAULT_CLIENT_RETRIES = 5;
public static final String NAME = "NAME"; public static final String NAME = "NAME";
public static final String VERSIONS = "VERSIONS"; public static final String VERSIONS = "VERSIONS";
public static final String IN_MEMORY = "IN_MEMORY"; public static final String IN_MEMORY = "IN_MEMORY";
/** /**
* This is a retry backoff multiplier table similar to the BSD TCP syn * This is a retry backoff multiplier table similar to the BSD TCP syn
* backoff table, a bit more aggressive than simple exponential backoff. * backoff table, a bit more aggressive than simple exponential backoff.
*/ */
public static int RETRY_BACKOFF[] = { 1, 1, 1, 1, 2, 4, 8, 16, 32, 64 }; public static int RETRY_BACKOFF[] = { 1, 1, 1, 1, 2, 4, 8, 16, 32, 64 };
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,210 +1,210 @@
/** /**
* Copyright 2007 The Apache Software Foundation * Copyright 2007 The Apache Software Foundation
* *
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.hadoop.hbase.ipc; package org.apache.hadoop.hbase.ipc;
import java.io.IOException; import java.io.IOException;
import org.apache.hadoop.hbase.filter.RowFilterInterface; import org.apache.hadoop.hbase.filter.RowFilterInterface;
import org.apache.hadoop.hbase.io.BatchUpdate; import org.apache.hadoop.hbase.io.BatchUpdate;
import org.apache.hadoop.hbase.io.Cell; import org.apache.hadoop.hbase.io.Cell;
import org.apache.hadoop.hbase.io.RowResult; import org.apache.hadoop.hbase.io.RowResult;
import org.apache.hadoop.ipc.VersionedProtocol; import org.apache.hadoop.ipc.VersionedProtocol;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.NotServingRegionException;
/** /**
* Clients interact with HRegionServers using a handle to the HRegionInterface. * Clients interact with HRegionServers using a handle to the HRegionInterface.
*/ */
public interface HRegionInterface extends VersionedProtocol { public interface HRegionInterface extends VersionedProtocol {
/** /**
* Protocol version. * Protocol version.
* Upped to 3 when we went from Text to byte arrays for row and column names. * Upped to 3 when we went from Text to byte arrays for row and column names.
*/ */
public static final long versionID = 3L; public static final long versionID = 3L;
/** /**
* Get metainfo about an HRegion * Get metainfo about an HRegion
* *
* @param regionName name of the region * @param regionName name of the region
* @return HRegionInfo object for region * @return HRegionInfo object for region
* @throws NotServingRegionException * @throws NotServingRegionException
*/ */
public HRegionInfo getRegionInfo(final byte [] regionName) public HRegionInfo getRegionInfo(final byte [] regionName)
throws NotServingRegionException; throws NotServingRegionException;
/** /**
* Retrieve a single value from the specified region for the specified row * Retrieve a single value from the specified region for the specified row
* and column keys * and column keys
* *
* @param regionName name of region * @param regionName name of region
* @param row row key * @param row row key
* @param column column key * @param column column key
* @return alue for that region/row/column * @return alue for that region/row/column
* @throws IOException * @throws IOException
*/ */
public Cell get(final byte [] regionName, final byte [] row, final byte [] column) public Cell get(final byte [] regionName, final byte [] row, final byte [] column)
throws IOException; throws IOException;
/** /**
* Get the specified number of versions of the specified row and column * Get the specified number of versions of the specified row and column
* *
* @param regionName region name * @param regionName region name
* @param row row key * @param row row key
* @param column column key * @param column column key
* @param numVersions number of versions to return * @param numVersions number of versions to return
* @return array of values * @return array of values
* @throws IOException * @throws IOException
*/ */
public Cell[] get(final byte [] regionName, final byte [] row, public Cell[] get(final byte [] regionName, final byte [] row,
final byte [] column, final int numVersions) final byte [] column, final int numVersions)
throws IOException; throws IOException;
/** /**
* Get the specified number of versions of the specified row and column with * Get the specified number of versions of the specified row and column with
* the specified timestamp. * the specified timestamp.
* *
* @param regionName region name * @param regionName region name
* @param row row key * @param row row key
* @param column column key * @param column column key
* @param timestamp timestamp * @param timestamp timestamp
* @param numVersions number of versions to return * @param numVersions number of versions to return
* @return array of values * @return array of values
* @throws IOException * @throws IOException
*/ */
public Cell[] get(final byte [] regionName, final byte [] row, public Cell[] get(final byte [] regionName, final byte [] row,
final byte [] column, final long timestamp, final int numVersions) final byte [] column, final long timestamp, final int numVersions)
throws IOException; throws IOException;
/** /**
* Return all the data for the row that matches <i>row</i> exactly, * Return all the data for the row that matches <i>row</i> exactly,
* or the one that immediately preceeds it. * or the one that immediately preceeds it.
* *
* @param regionName region name * @param regionName region name
* @param row row key * @param row row key
* @return map of values * @return map of values
* @throws IOException * @throws IOException
*/ */
public RowResult getClosestRowBefore(final byte [] regionName, public RowResult getClosestRowBefore(final byte [] regionName,
final byte [] row) final byte [] row)
throws IOException; throws IOException;
/** /**
* Get selected columns for the specified row at a given timestamp. * Get selected columns for the specified row at a given timestamp.
* *
* @param regionName region name * @param regionName region name
* @param row row key * @param row row key
* @return map of values * @return map of values
* @throws IOException * @throws IOException
*/ */
public RowResult getRow(final byte [] regionName, final byte [] row, public RowResult getRow(final byte [] regionName, final byte [] row,
final byte[][] columns, final long ts) final byte[][] columns, final long ts)
throws IOException; throws IOException;
/** /**
* Applies a batch of updates via one RPC * Applies a batch of updates via one RPC
* *
* @param regionName name of the region to update * @param regionName name of the region to update
* @param b BatchUpdate * @param b BatchUpdate
* @throws IOException * @throws IOException
*/ */
public void batchUpdate(final byte [] regionName, final BatchUpdate b) public void batchUpdate(final byte [] regionName, final BatchUpdate b)
throws IOException; throws IOException;
/** /**
* Delete all cells that match the passed row and column and whose * Delete all cells that match the passed row and column and whose
* timestamp is equal-to or older than the passed timestamp. * timestamp is equal-to or older than the passed timestamp.
* *
* @param regionName region name * @param regionName region name
* @param row row key * @param row row key
* @param column column key * @param column column key
* @param timestamp Delete all entries that have this timestamp or older * @param timestamp Delete all entries that have this timestamp or older
* @throws IOException * @throws IOException
*/ */
public void deleteAll(byte [] regionName, byte [] row, byte [] column, public void deleteAll(byte [] regionName, byte [] row, byte [] column,
long timestamp) long timestamp)
throws IOException; throws IOException;
/** /**
* Delete all cells that match the passed row and whose * Delete all cells that match the passed row and whose
* timestamp is equal-to or older than the passed timestamp. * timestamp is equal-to or older than the passed timestamp.
* *
* @param regionName region name * @param regionName region name
* @param row row key * @param row row key
* @param timestamp Delete all entries that have this timestamp or older * @param timestamp Delete all entries that have this timestamp or older
* @throws IOException * @throws IOException
*/ */
public void deleteAll(byte [] regionName, byte [] row, long timestamp) public void deleteAll(byte [] regionName, byte [] row, long timestamp)
throws IOException; throws IOException;
/** /**
* Delete all cells for a row with matching column family with timestamps * Delete all cells for a row with matching column family with timestamps
* less than or equal to <i>timestamp</i>. * less than or equal to <i>timestamp</i>.
* *
* @param regionName The name of the region to operate on * @param regionName The name of the region to operate on
* @param row The row to operate on * @param row The row to operate on
* @param family The column family to match * @param family The column family to match
* @param timestamp Timestamp to match * @param timestamp Timestamp to match
*/ */
public void deleteFamily(byte [] regionName, byte [] row, byte [] family, public void deleteFamily(byte [] regionName, byte [] row, byte [] family,
long timestamp) long timestamp)
throws IOException; throws IOException;
// //
// remote scanner interface // remote scanner interface
// //
/** /**
* Opens a remote scanner with a RowFilter. * Opens a remote scanner with a RowFilter.
* *
* @param regionName name of region to scan * @param regionName name of region to scan
* @param columns columns to scan. If column name is a column family, all * @param columns columns to scan. If column name is a column family, all
* columns of the specified column family are returned. Its also possible * columns of the specified column family are returned. Its also possible
* to pass a regex for column family name. A column name is judged to be * to pass a regex for column family name. A column name is judged to be
* regex if it contains at least one of the following characters: * regex if it contains at least one of the following characters:
* <code>\+|^&*$[]]}{)(</code>. * <code>\+|^&*$[]]}{)(</code>.
* @param startRow starting row to scan * @param startRow starting row to scan
* @param timestamp only return values whose timestamp is <= this value * @param timestamp only return values whose timestamp is <= this value
* @param filter RowFilter for filtering results at the row-level. * @param filter RowFilter for filtering results at the row-level.
* *
* @return scannerId scanner identifier used in other calls * @return scannerId scanner identifier used in other calls
* @throws IOException * @throws IOException
*/ */
public long openScanner(final byte [] regionName, final byte [][] columns, public long openScanner(final byte [] regionName, final byte [][] columns,
final byte [] startRow, long timestamp, RowFilterInterface filter) final byte [] startRow, long timestamp, RowFilterInterface filter)
throws IOException; throws IOException;
/** /**
* Get the next set of values * Get the next set of values
* @param scannerId clientId passed to openScanner * @param scannerId clientId passed to openScanner
* @return map of values * @return map of values
* @throws IOException * @throws IOException
*/ */
public RowResult next(long scannerId) throws IOException; public RowResult next(long scannerId) throws IOException;
/** /**
* Close a scanner * Close a scanner
* *
* @param scannerId the scanner id returned by openScanner * @param scannerId the scanner id returned by openScanner
* @throws IOException * @throws IOException
*/ */
public void close(long scannerId) throws IOException; public void close(long scannerId) throws IOException;
} }

View File

@ -1,151 +1,151 @@
/** /**
* Copyright 2007 The Apache Software Foundation * Copyright 2007 The Apache Software Foundation
* *
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.hadoop.hbase.client; package org.apache.hadoop.hbase.client;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import org.apache.hadoop.hbase.HBaseClusterTestCase; import org.apache.hadoop.hbase.HBaseClusterTestCase;
import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.io.BatchUpdate; import org.apache.hadoop.hbase.io.BatchUpdate;
import org.apache.hadoop.hbase.io.Cell; import org.apache.hadoop.hbase.io.Cell;
import org.apache.hadoop.hbase.io.RowResult; import org.apache.hadoop.hbase.io.RowResult;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
/** /**
* Test batch updates * Test batch updates
*/ */
public class TestBatchUpdate extends HBaseClusterTestCase { public class TestBatchUpdate extends HBaseClusterTestCase {
private static final String CONTENTS_STR = "contents:"; private static final String CONTENTS_STR = "contents:";
private static final byte [] CONTENTS = Bytes.toBytes(CONTENTS_STR); private static final byte [] CONTENTS = Bytes.toBytes(CONTENTS_STR);
private static final String SMALLFAM_STR = "smallfam:"; private static final String SMALLFAM_STR = "smallfam:";
private static final byte [] SMALLFAM = Bytes.toBytes(SMALLFAM_STR); private static final byte [] SMALLFAM = Bytes.toBytes(SMALLFAM_STR);
private static final int SMALL_LENGTH = 1; private static final int SMALL_LENGTH = 1;
private static final int NB_BATCH_ROWS = 10; private static final int NB_BATCH_ROWS = 10;
private byte[] value; private byte[] value;
private byte[] smallValue; private byte[] smallValue;
private HTableDescriptor desc = null; private HTableDescriptor desc = null;
private HTable table = null; private HTable table = null;
/** /**
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
*/ */
public TestBatchUpdate() throws UnsupportedEncodingException { public TestBatchUpdate() throws UnsupportedEncodingException {
super(); super();
value = "abcd".getBytes(HConstants.UTF8_ENCODING); value = "abcd".getBytes(HConstants.UTF8_ENCODING);
smallValue = "a".getBytes(HConstants.UTF8_ENCODING); smallValue = "a".getBytes(HConstants.UTF8_ENCODING);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
this.desc = new HTableDescriptor("test"); this.desc = new HTableDescriptor("test");
desc.addFamily(new HColumnDescriptor(CONTENTS_STR)); desc.addFamily(new HColumnDescriptor(CONTENTS_STR));
desc.addFamily(new HColumnDescriptor(SMALLFAM, desc.addFamily(new HColumnDescriptor(SMALLFAM,
HColumnDescriptor.DEFAULT_VERSIONS, HColumnDescriptor.DEFAULT_VERSIONS,
HColumnDescriptor.DEFAULT_COMPRESSION, HColumnDescriptor.DEFAULT_COMPRESSION,
HColumnDescriptor.DEFAULT_IN_MEMORY, HColumnDescriptor.DEFAULT_IN_MEMORY,
HColumnDescriptor.DEFAULT_BLOCKCACHE, SMALL_LENGTH, HColumnDescriptor.DEFAULT_BLOCKCACHE, SMALL_LENGTH,
HColumnDescriptor.DEFAULT_TTL, HColumnDescriptor.DEFAULT_BLOOMFILTER)); HColumnDescriptor.DEFAULT_TTL, HColumnDescriptor.DEFAULT_BLOOMFILTER));
HBaseAdmin admin = new HBaseAdmin(conf); HBaseAdmin admin = new HBaseAdmin(conf);
admin.createTable(desc); admin.createTable(desc);
table = new HTable(conf, desc.getName()); table = new HTable(conf, desc.getName());
} }
/** /**
* @throws IOException * @throws IOException
*/ */
public void testBatchUpdate() throws IOException { public void testBatchUpdate() throws IOException {
BatchUpdate bu = new BatchUpdate("row1"); BatchUpdate bu = new BatchUpdate("row1");
bu.put(CONTENTS, value); bu.put(CONTENTS, value);
bu.delete(CONTENTS); bu.delete(CONTENTS);
table.commit(bu); table.commit(bu);
bu = new BatchUpdate("row2"); bu = new BatchUpdate("row2");
bu.put(CONTENTS, value); bu.put(CONTENTS, value);
table.commit(bu); table.commit(bu);
byte [][] columns = { CONTENTS }; byte [][] columns = { CONTENTS };
Scanner scanner = table.getScanner(columns, HConstants.EMPTY_START_ROW); Scanner scanner = table.getScanner(columns, HConstants.EMPTY_START_ROW);
for (RowResult r : scanner) { for (RowResult r : scanner) {
for(Map.Entry<byte [], Cell> e: r.entrySet()) { for(Map.Entry<byte [], Cell> e: r.entrySet()) {
System.out.println(r.getRow() + ": row: " + e.getKey() + " value: " + System.out.println(r.getRow() + ": row: " + e.getKey() + " value: " +
new String(e.getValue().getValue(), HConstants.UTF8_ENCODING)); new String(e.getValue().getValue(), HConstants.UTF8_ENCODING));
} }
} }
} }
public void testBatchUpdateMaxLength() { public void testBatchUpdateMaxLength() {
// Test for a single good value // Test for a single good value
BatchUpdate batchUpdate = new BatchUpdate("row1"); BatchUpdate batchUpdate = new BatchUpdate("row1");
batchUpdate.put(SMALLFAM, value); batchUpdate.put(SMALLFAM, value);
try { try {
table.commit(batchUpdate); table.commit(batchUpdate);
fail("Value is too long, should throw exception"); fail("Value is too long, should throw exception");
} catch (IOException e) { } catch (IOException e) {
// This is expected // This is expected
} }
// Try to see if it's still inserted // Try to see if it's still inserted
try { try {
Cell cell = table.get("row1", SMALLFAM_STR); Cell cell = table.get("row1", SMALLFAM_STR);
assertNull(cell); assertNull(cell);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
fail("This is unexpected"); fail("This is unexpected");
} }
// Try to put a good value // Try to put a good value
batchUpdate = new BatchUpdate("row1"); batchUpdate = new BatchUpdate("row1");
batchUpdate.put(SMALLFAM, smallValue); batchUpdate.put(SMALLFAM, smallValue);
try { try {
table.commit(batchUpdate); table.commit(batchUpdate);
} catch (IOException e) { } catch (IOException e) {
fail("Value is long enough, should not throw exception"); fail("Value is long enough, should not throw exception");
} }
} }
public void testRowsBatchUpdate() { public void testRowsBatchUpdate() {
ArrayList<BatchUpdate> rowsUpdate = new ArrayList<BatchUpdate>(); ArrayList<BatchUpdate> rowsUpdate = new ArrayList<BatchUpdate>();
for(int i = 0; i < NB_BATCH_ROWS; i++) { for(int i = 0; i < NB_BATCH_ROWS; i++) {
BatchUpdate batchUpdate = new BatchUpdate("row"+i); BatchUpdate batchUpdate = new BatchUpdate("row"+i);
batchUpdate.put(CONTENTS, value); batchUpdate.put(CONTENTS, value);
rowsUpdate.add(batchUpdate); rowsUpdate.add(batchUpdate);
} }
try { try {
table.commit(rowsUpdate); table.commit(rowsUpdate);
byte [][] columns = { CONTENTS }; byte [][] columns = { CONTENTS };
Scanner scanner = table.getScanner(columns, HConstants.EMPTY_START_ROW); Scanner scanner = table.getScanner(columns, HConstants.EMPTY_START_ROW);
int nbRows = 0; int nbRows = 0;
for(RowResult row : scanner) for(RowResult row : scanner)
nbRows++; nbRows++;
assertEquals(NB_BATCH_ROWS, nbRows); assertEquals(NB_BATCH_ROWS, nbRows);
} catch (IOException e) { } catch (IOException e) {
fail("This is unexpected : " + e); fail("This is unexpected : " + e);
} }
} }
} }