@Override public boolean equals(Object o) { if (o instanceof Location) { Location ol = ((Location) o); if (tserverInstance == ol.tserverInstance) { return true; } return tserverInstance.equals(ol.tserverInstance); } return false; } }
@Override public boolean equals(Object o) { if (o instanceof TserverGroupInfo) { TserverGroupInfo otgi = (TserverGroupInfo) o; return tsi.equals(otgi.tsi); } return false; }
int index = r.nextInt(underCapacityTServer.size()); TServerInstance dest = underCapacityTServer.get(index); if (dest.equals(e.getKey())) continue; migrationsOut.add(new TabletMigration(ke, e.getKey(), dest));
public synchronized void remove(TServerInstance server) { String zPath = null; for (Entry<String,TServerInfo> entry : current.entrySet()) { if (entry.getValue().instance.equals(server)) { zPath = entry.getKey(); break; } } if (zPath == null) return; current.remove(zPath); currentInstances.remove(server); log.info("Removing zookeeper lock for {}", server); String fullpath = context.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + zPath; try { context.getZooReaderWriter().recursiveDelete(fullpath, SKIP); } catch (Exception e) { String msg = "error removing tablet server lock"; // ACCUMULO-3651 Changed level to error and added FATAL to message for slf4j compatibility log.error("FATAL: {}", msg, e); Halt.halt(msg, -1); } getZooCache().clear(fullpath); } }
@Override public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException { if (assignments.size() != 1) throw new IllegalArgumentException("There is only one root tablet"); Assignment assignment = assignments.iterator().next(); if (assignment.tablet.compareTo(RootTable.EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location"); String value = assignment.server.getLocation() + "|" + assignment.server.getSession(); Iterator<TabletLocationState> currentIter = iterator(); TabletLocationState current = currentIter.next(); if (current.current != null) { throw new DistributedStoreException( "Trying to set the root tablet location: it is already set to " + current.current); } if (!current.future.equals(assignment.server)) { throw new DistributedStoreException("Root tablet is already assigned to " + current.future); } store.put(RootTable.ZROOT_TABLET_LOCATION, value.getBytes(UTF_8)); store.put(RootTable.ZROOT_TABLET_LAST_LOCATION, value.getBytes(UTF_8)); // Make the following unnecessary by making the entire update atomic store.remove(RootTable.ZROOT_TABLET_FUTURE_LOCATION); log.debug("Put down root tablet location"); }
current.put(zPath, tServerInfo); currentInstances.put(instance, tServerInfo); } else if (!info.instance.equals(instance)) { doomed.add(info.instance); updates.add(instance);
if (!instance.equals(future)) { log.info("Table {} has been assigned to {} which is not {}", extent, future, instance); return null;
if (dest != null && tls.current != null && !dest.equals(tls.current)) { return TabletGoalState.UNASSIGNED;
private static Pair<Text,KeyExtent> verifyRootTablet(ServerContext context, TServerInstance instance) throws AccumuloException { ZooTabletStateStore store = new ZooTabletStateStore(context); if (!store.iterator().hasNext()) { throw new AccumuloException("Illegal state: location is not set in zookeeper"); } TabletLocationState next = store.iterator().next(); if (!instance.equals(next.future)) { throw new AccumuloException("Future location is not to this server for the root tablet"); } if (next.current != null) { throw new AccumuloException("Root tablet already has a location set"); } try { return new Pair<>(new Text(MetadataTableUtil.getRootTabletDir(context)), null); } catch (IOException e) { throw new AccumuloException(e); } }
if (server.equals(this.master.migrations.get(tls.extent))) this.master.migrations.remove(tls.extent); break; case ASSIGNED_TO_DEAD_SERVER: assignedToDeadServers.add(tls); if (server.equals(this.master.migrations.get(tls.extent))) this.master.migrations.remove(tls.extent); TServerInstance tserver = tls.futureOrCurrent();
@Override public boolean equals(Object o) { if (o instanceof Location) { Location ol = ((Location) o); if (tserverInstance == ol.tserverInstance) { return true; } return tserverInstance.equals(ol.tserverInstance); } return false; } }
@Override public boolean equals(Object o) { if (o instanceof TserverGroupInfo) { TserverGroupInfo otgi = (TserverGroupInfo) o; return tsi.equals(otgi.tsi); } return false; }
self.putLastLocation(m); if (lastLocation != null && !lastLocation.equals(self)) lastLocation.clearLastLocation(m);
public TabletState getState(Set<TServerInstance> liveServers) { TServerInstance server = getServer(); if (server == null) return TabletState.UNASSIGNED; if (server.equals(current) || server.equals(future)) { if (liveServers.contains(server)) if (server.equals(future)) { return TabletState.ASSIGNED; } else { return TabletState.HOSTED; } else { return TabletState.ASSIGNED_TO_DEAD_SERVER; } } // server == last return TabletState.UNASSIGNED; }
public static void replaceDatafiles(ServerContext context, KeyExtent extent, Set<FileRef> datafilesToDelete, Set<FileRef> scanFiles, FileRef path, Long compactionId, DataFileValue size, String address, TServerInstance lastLocation, ZooLock zooLock, boolean insertDeleteFlags) { if (insertDeleteFlags) { // add delete flags for those paths before the data file reference is removed MetadataTableUtil.addDeleteEntries(extent, datafilesToDelete, context); } // replace data file references to old mapfiles with the new mapfiles Mutation m = new Mutation(extent.getMetadataEntry()); for (FileRef pathToRemove : datafilesToDelete) m.putDelete(DataFileColumnFamily.NAME, pathToRemove.meta()); for (FileRef scanFile : scanFiles) m.put(ScanFileColumnFamily.NAME, scanFile.meta(), new Value(new byte[0])); if (size.getNumEntries() > 0) m.put(DataFileColumnFamily.NAME, path.meta(), new Value(size.encode())); if (compactionId != null) TabletsSection.ServerColumnFamily.COMPACT_COLUMN.put(m, new Value(("" + compactionId).getBytes())); TServerInstance self = getTServerInstance(address, zooLock); self.putLastLocation(m); // remove the old location if (lastLocation != null && !lastLocation.equals(self)) lastLocation.clearLastLocation(m); MetadataTableUtil.update(context, zooLock, m, extent); }
public synchronized TServerConnection getConnection(TServerInstance server) throws TException { if (server == null) return null; TServerInfo serverInfo = current.get(server.hostPort()); // lock was lost? if (serverInfo == null) return null; // instance changed? if (!serverInfo.instance.equals(server)) return null; TServerConnection result = serverInfo.connection; return result; }
private static Pair<Text,KeyExtent> verifyRootTablet(KeyExtent extent, TServerInstance instance) throws DistributedStoreException, AccumuloException { ZooTabletStateStore store = new ZooTabletStateStore(); if (!store.iterator().hasNext()) { throw new AccumuloException("Illegal state: location is not set in zookeeper"); } TabletLocationState next = store.iterator().next(); if (!instance.equals(next.future)) { throw new AccumuloException("Future location is not to this server for the root tablet"); } if (next.current != null) { throw new AccumuloException("Root tablet already has a location set"); } return new Pair<Text,KeyExtent>(new Text(Constants.ZROOT_TABLET), null); }
@Override public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException { if (assignments.size() != 1) throw new IllegalArgumentException("There is only one root tablet"); Assignment assignment = assignments.iterator().next(); if (assignment.tablet.compareTo(Constants.ROOT_TABLET_EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location"); String value = AddressUtil.toString(assignment.server.getLocation()) + "|" + assignment.server.getSession(); Iterator<TabletLocationState> currentIter = iterator(); TabletLocationState current = currentIter.next(); if (current.current != null) { throw new IllegalDSException("Trying to set the root tablet location: it is already set to " + current.current); } if (!current.future.equals(assignment.server)) { throw new IllegalDSException("Root tablet is already assigned to " + current.future); } store.put(Constants.ZROOT_TABLET_LOCATION, value.getBytes(UTF_8)); store.put(Constants.ZROOT_TABLET_LAST_LOCATION, value.getBytes(UTF_8)); // Make the following unnecessary by making the entire update atomic store.remove(Constants.ZROOT_TABLET_FUTURE_LOCATION); log.debug("Put down root tablet location"); }
public static void replaceDatafiles(KeyExtent extent, Set<String> datafilesToDelete, Set<String> scanFiles, String path, Long compactionId, DataFileValue size, TCredentials credentials, String address, TServerInstance lastLocation, ZooLock zooLock, boolean insertDeleteFlags) { if (insertDeleteFlags) { // add delete flags for those paths before the data file reference is removed addDeleteEntries(extent, datafilesToDelete, credentials); } // replace data file references to old mapfiles with the new mapfiles Mutation m = new Mutation(extent.getMetadataEntry()); for (String pathToRemove : datafilesToDelete) m.putDelete(Constants.METADATA_DATAFILE_COLUMN_FAMILY, new Text(pathToRemove)); for (String scanFile : scanFiles) m.put(Constants.METADATA_SCANFILE_COLUMN_FAMILY, new Text(scanFile), new Value(new byte[0])); if (size.getNumEntries() > 0) m.put(Constants.METADATA_DATAFILE_COLUMN_FAMILY, new Text(path), new Value(size.encode())); if (compactionId != null) Constants.METADATA_COMPACT_COLUMN.put(m, new Value(Long.toString(compactionId).getBytes(UTF_8))); TServerInstance self = getTServerInstance(address, zooLock); self.putLastLocation(m); // remove the old location if (lastLocation != null && !lastLocation.equals(self)) lastLocation.clearLastLocation(m); update(credentials, zooLock, m); }
private static Pair<Text,KeyExtent> verifyRootTablet(KeyExtent extent, TServerInstance instance) throws DistributedStoreException, AccumuloException { ZooTabletStateStore store = new ZooTabletStateStore(); if (!store.iterator().hasNext()) { throw new AccumuloException("Illegal state: location is not set in zookeeper"); } TabletLocationState next = store.iterator().next(); if (!instance.equals(next.future)) { throw new AccumuloException("Future location is not to this server for the root tablet"); } if (next.current != null) { throw new AccumuloException("Root tablet already has a location set"); } try { return new Pair<>(new Text(MetadataTableUtil.getRootTabletDir()), null); } catch (IOException e) { throw new AccumuloException(e); } }