Projects >> accumulo >>38ff0000879af97d24372cb004a81e10901e4276

Chunk
Conflicting content
  }
    this.fs = fs;
  final Map systemProperties = new HashMap();
  Map users = new HashMap();
  final FileSystem fs;
<<<<<<< HEAD

=======
  final AtomicInteger tableIdCounter = new AtomicInteger(0);
  
>>>>>>> 9fcca2ede18a7b96bee4edb5ab105316ac383604
  MockAccumulo(FileSystem fs) {
Solution content
  final Map systemProperties = new HashMap();
  Map users = new HashMap();
  final FileSystem fs;
  final AtomicInteger tableIdCounter = new AtomicInteger(0);

  MockAccumulo(FileSystem fs) {
    this.fs = fs;
  }
File
MockAccumulo.java
Developer's decision
Version 2
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
  }

  public void createTable(String username, String tableName, boolean useVersions, TimeType timeType) {
<<<<<<< HEAD
    String namespace = Tables.qualify(tableName).getFirst();

    if (!namespaceExists(namespace)) {
      return;
    }

    MockNamespace n = namespaces.get(namespace);
    MockTable t = new MockTable(n, useVersions, timeType);
=======
    MockTable t = new MockTable(useVersions, timeType, Integer.toString(tableIdCounter.incrementAndGet()));
>>>>>>> 9fcca2ede18a7b96bee4edb5ab105316ac383604
    t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
    t.setNamespaceName(namespace);
    t.setNamespace(n);
Solution content
  }

  public void createTable(String username, String tableName, boolean useVersions, TimeType timeType) {
    String namespace = Tables.qualify(tableName).getFirst();

    if (!namespaceExists(namespace)) {
      return;
    }

    MockNamespace n = namespaces.get(namespace);
    MockTable t = new MockTable(n, useVersions, timeType, Integer.toString(tableIdCounter.incrementAndGet()));
    t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
    t.setNamespaceName(namespace);
    t.setNamespace(n);
File
MockAccumulo.java
Developer's decision
Manual
Kind of conflict
If statement
Method invocation
Variable
Chunk
Conflicting content
  Map> userPermissions = new HashMap>();
  private TimeType timeType;
  SortedSet splits = new ConcurrentSkipListSet();
<<<<<<< HEAD
  Map> localityGroups = new TreeMap>();
  private MockNamespace namespace;
  private String namespaceName;
=======
  Map> localityGroups = new TreeMap>();
  private String tableId;
>>>>>>> 9fcca2ede18a7b96bee4edb5ab105316ac383604
  
  MockTable(boolean limitVersion, TimeType timeType, String tableId) {
    this.timeType = timeType;
Solution content
  Map> userPermissions = new HashMap>();
  private TimeType timeType;
  SortedSet splits = new ConcurrentSkipListSet();
  Map> localityGroups = new TreeMap>();
  private MockNamespace namespace;
  private String namespaceName;
  private String tableId;
  
  MockTable(boolean limitVersion, TimeType timeType, String tableId) {
    this.timeType = timeType;
File
MockTable.java
Developer's decision
Combination
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
    if (reAdd)
      splits.add(start);
  }
<<<<<<< HEAD
  
  public void setNamespaceName(String n) {
    this.namespaceName = n;
  }
  
  public void setNamespace(MockNamespace n) {
    this.namespace = n;
  }
  
  public String getNamespaceName() {
    return this.namespaceName;
  }
  
  public MockNamespace getNamespace() {
    return this.namespace;
=======

  public String getTableId() {
    return this.tableId;
>>>>>>> 9fcca2ede18a7b96bee4edb5ab105316ac383604
  }
}
Solution content
    if (reAdd)
      splits.add(start);
  }
  
  public void setNamespaceName(String n) {
    this.namespaceName = n;
  }
  
  public void setNamespace(MockNamespace n) {
    this.namespace = n;
  }
  
  public String getNamespaceName() {
    return this.namespaceName;
  }
  
  public MockNamespace getNamespace() {
    return this.namespace;
  }

  public String getTableId() {
    return this.tableId;
  }
}
File
MockTable.java
Developer's decision
Concatenation
Kind of conflict
Attribute
Method declaration
Method signature
Return statement
Chunk
Conflicting content
  @Override
  public Collection getSplits(String tableName, int maxSplits) throws TableNotFoundException {
public class MockTableOperations extends MockTableOperationsImpl {

  MockTableOperations(MockAccumulo acu, String username) {
<<<<<<< HEAD
    super(acu,username);
=======
    this.acu = acu;
    this.username = username;
  }

  @Override
  public SortedSet list() {
    return new TreeSet(acu.tables.keySet());
  }

  @Override
  public boolean exists(String tableName) {
    return acu.tables.containsKey(tableName);
  }

  @Override
  public void create(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException {
    if (!tableName.matches(Constants.VALID_TABLE_NAME_REGEX)) {
      throw new IllegalArgumentException();
    }
    create(tableName, true, TimeType.MILLIS);
  }

  @Override
  public void create(String tableName, boolean versioningIter) throws AccumuloException, AccumuloSecurityException, TableExistsException {
    create(tableName, versioningIter, TimeType.MILLIS);
  }

  @Override
  public void create(String tableName, boolean versioningIter, TimeType timeType) throws AccumuloException, AccumuloSecurityException, TableExistsException {
    if (!tableName.matches(Constants.VALID_TABLE_NAME_REGEX)) {
      throw new IllegalArgumentException();
    }
    if (exists(tableName))
      throw new TableExistsException(tableName, tableName, "");
    acu.createTable(username, tableName, versioningIter, timeType);
  }

  @Override
      AccumuloSecurityException, TableNotFoundException {
  public void addSplits(String tableName, SortedSet partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    acu.addSplits(tableName, partitionKeys);
  }

  @Deprecated
  @Override
  public Collection getSplits(String tableName) throws TableNotFoundException {
    return listSplits(tableName);
  }

  @Deprecated
    long time = System.currentTimeMillis();
    return listSplits(tableName);
  }

  @Override
  public Collection listSplits(String tableName) throws TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    return acu.getSplits(tableName);
  }

  @Override
  public Collection listSplits(String tableName, int maxSplits) throws TableNotFoundException {
    return listSplits(tableName);
  }

  @Override
  public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    acu.tables.remove(tableName);
  }

  @Override
  public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
      TableExistsException {
    if (!exists(oldTableName))
      throw new TableNotFoundException(oldTableName, oldTableName, "");
    if (exists(newTableName))
      throw new TableExistsException(newTableName, newTableName, "");
    MockTable t = acu.tables.remove(oldTableName);
    acu.tables.put(newTableName, t);
  }

  @Deprecated
  @Override
  public void flush(String tableName) throws AccumuloException, AccumuloSecurityException {}

  @Override
  public void setProperty(String tableName, String property, String value) throws AccumuloException, AccumuloSecurityException {
    acu.tables.get(tableName).settings.put(property, value);
  }

  @Override
  public void removeProperty(String tableName, String property) throws AccumuloException, AccumuloSecurityException {
    acu.tables.get(tableName).settings.remove(property);
  }

  @Override
  public Iterable> getProperties(String tableName) throws TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    return acu.tables.get(tableName).settings.entrySet();
  }

  @Override
  public void setLocalityGroups(String tableName, Map> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    acu.tables.get(tableName).setLocalityGroups(groups);
  }

  @Override
  public Map> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    return acu.tables.get(tableName).getLocalityGroups();
  }

  @Override
  public Set splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException,
      TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    return Collections.singleton(range);
  }

  @Override
  public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws IOException, AccumuloException,
    MockTable table = acu.tables.get(tableName);
    if (table == null) {
      throw new TableNotFoundException(null, tableName, "The table was not found");
    }
    Path importPath = new Path(dir);
    Path failurePath = new Path(failureDir);

    FileSystem fs = acu.getFileSystem();
    /*
     * check preconditions
     */
    // directories are directories
    if (fs.isFile(importPath)) {
  @Override
      throw new IOException("Import path must be a directory.");
    }
    if (fs.isFile(failurePath)) {
      throw new IOException("Failure path must be a directory.");
    }
    // failures are writable
    Path createPath = failurePath.suffix("/.createFile");
    FSDataOutputStream createStream = null;
    try {
      createStream = fs.create(createPath);
    } catch (IOException e) {
      throw new IOException("Error path is not writable.");
    } finally {
      if (createStream != null) {
        createStream.close();
      }
    }
    fs.delete(createPath, false);
    // failures are empty
    FileStatus[] failureChildStats = fs.listStatus(failurePath);
    if (failureChildStats.length > 0) {
      throw new IOException("Error path must be empty.");
    }
    /*
     * Begin the import - iterate the files in the path
     */
    for (FileStatus importStatus : fs.listStatus(importPath)) {
      try {
        FileSKVIterator importIterator = FileOperations.getInstance().openReader(importStatus.getPath().toString(), true, fs, fs.getConf(),
            AccumuloConfiguration.getDefaultConfiguration());
        while (importIterator.hasTop()) {
          Key key = importIterator.getTopKey();
          Value value = importIterator.getTopValue();
          if (setTime) {
            key.setTimestamp(time);
          }
          Mutation mutation = new Mutation(key.getRow());
          if (!key.isDeleted()) {
            mutation.put(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()), key.getTimestamp(),
                value);
          } else {
            mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()),
                key.getTimestamp());
          }
          table.addMutation(mutation);
          importIterator.next();
        }
      } catch (Exception e) {
        FSDataOutputStream failureWriter = null;
        DataInputStream failureReader = null;
        try {
          failureWriter = fs.create(failurePath.suffix("/" + importStatus.getPath().getName()));
          failureReader = fs.open(importStatus.getPath());
          int read = 0;
          byte[] buffer = new byte[1024];
          while (-1 != (read = failureReader.read(buffer))) {
            failureWriter.write(buffer, 0, read);
          }
        } finally {
          if (failureReader != null)
            failureReader.close();
          if (failureWriter != null)
            failureWriter.close();
        }
      }
      fs.delete(importStatus.getPath(), true);
    }
  }

  @Override
  public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
  }

  @Override
  public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
  }

  @Override
  public void clearLocatorCache(String tableName) throws TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
  }

  @Override
  public Map tableIdMap() {
    Map result = new HashMap();
    for (Entry entry : acu.tables.entrySet()) {
      result.put(entry.getKey(), entry.getValue().getTableId());
    }
    return result;
  }

  public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    acu.merge(tableName, start, end);
  }

  @Override
  public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
    MockTable t = acu.tables.get(tableName);
    Text startText = start != null ? new Text(start) : new Text();
    Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes());
    startText.append(ZERO, 0, 1);
    endText.append(ZERO, 0, 1);
    Set keep = new TreeSet(t.table.subMap(new Key(startText), new Key(endText)).keySet());
    t.table.keySet().removeAll(keep);
  }

  @Override
  public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException,
      AccumuloException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
  }

  @Override
  public void compact(String tableName, Text start, Text end, List iterators, boolean flush, boolean wait) throws AccumuloSecurityException,
      TableNotFoundException, AccumuloException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
  }

  @Override
  public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
  }

  @Override
  public void clone(String srcTableName, String newTableName, boolean flush, Map propertiesToSet, Set propertiesToExclude)
      throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
    throw new NotImplementedException();
  }

  @Override
  public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
    if (!exists(tableName))
      throw new TableNotFoundException(tableName, tableName, "");
  }

  @Override
  public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive)
      throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
    MockTable table = acu.tables.get(tableName);
    if (table == null)
      throw new TableNotFoundException(tableName, tableName, "no such table");

    return FindMax.findMax(new MockScanner(table, auths), startRow, startInclusive, endRow, endInclusive);
  }

  @Override
  public void importTable(String tableName, String exportDir) throws TableExistsException, AccumuloException, AccumuloSecurityException {
    throw new NotImplementedException();
  }

  @Override
  public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
    throw new NotImplementedException();
  }

  @Override
  public boolean testClassLoad(String tableName, String className, String asTypeName) throws AccumuloException, AccumuloSecurityException,
      TableNotFoundException {

    try {
      AccumuloVFSClassLoader.loadClass(className, Class.forName(asTypeName));
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      return false;
    }
    return true;
>>>>>>> 9fcca2ede18a7b96bee4edb5ab105316ac383604
  }
}
Solution content
public class MockTableOperations extends MockTableOperationsImpl {

  MockTableOperations(MockAccumulo acu, String username) {
    super(acu,username);
  }
}
File
MockTableOperations.java
Developer's decision
Version 1
Kind of conflict
Annotation
Attribute
Method declaration
Method invocation
Method signature
Return statement
Try statement
Chunk
Conflicting content
    tops.create("t3");
    String t1Id = tops.tableIdMap().get("t1"), t2Id = tops.tableIdMap().get("t2"), t3Id = tops.tableIdMap().get("t3");
    state = new TreeMap();
<<<<<<< HEAD:server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
    TServerInstance svr = mkts("10.0.0.1", "0x01020304");
    state.put(svr, status("t1", 10, "t2", 10, "t3", 10));
=======
    TServerInstance svr = mkts("10.0.0.1:1234", "0x01020304");
    state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
>>>>>>> 9fcca2ede18a7b96bee4edb5ab105316ac383604:server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
    
    Set migrations = Collections.emptySet();
    List migrationsOut = new ArrayList();
Solution content
    tops.create("t3");
    String t1Id = tops.tableIdMap().get("t1"), t2Id = tops.tableIdMap().get("t2"), t3Id = tops.tableIdMap().get("t3");
    state = new TreeMap();
    TServerInstance svr = mkts("10.0.0.1", "0x01020304");
    state.put(svr, status("t1", 10, "t2", 10, "t3", 10));
    state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
    
    Set migrations = Collections.emptySet();
    List migrationsOut = new ArrayList();
File
TableLoadBalancerTest.java
Developer's decision
Combination
Kind of conflict
Method invocation
Variable