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); } }
@Override public void suspend(Collection<TabletLocationState> tablets, Map<TServerInstance,List<Path>> logsForDeadServers, long suspensionTimestamp) throws DistributedStoreException { // No support for suspending root tablet. unassign(tablets, logsForDeadServers); }
protected static TabletStateStore getStoreForTablet(KeyExtent extent, ServerContext context) { if (extent.isRootTablet()) { return new ZooTabletStateStore(context); } else if (extent.isMeta()) { return new RootTabletStateStore(context); } else { return new MetaDataStateStore(context); } } }
@Override public void setFutureLocations(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); } store.put(RootTable.ZROOT_TABLET_FUTURE_LOCATION, value.getBytes(UTF_8)); }
watchers.add(new TabletGroupWatcher(this, new ZooTabletStateStore(new ZooStore(context)), watchers.get(1)) { @Override
@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"); }
scanning.set(true); Iterator<TabletLocationState> zooScanner = new ZooTabletStateStore(context).iterator();
public static void unassign(TabletLocationState tls) throws DistributedStoreException { TabletStateStore store; if (tls.extent.isRootTablet()) { store = new ZooTabletStateStore(); } else { store = new MetaDataStateStore(); } store.unassign(Collections.singletonList(tls)); }
@Override public void setFutureLocations(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); } store.put(RootTable.ZROOT_TABLET_FUTURE_LOCATION, value.getBytes(UTF_8)); }
@Override public void suspend(Collection<TabletLocationState> tablets, Map<TServerInstance,List<Path>> logsForDeadServers, long suspensionTimestamp) throws DistributedStoreException { // No support for suspending root tablet. unassign(tablets, logsForDeadServers); }
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); }
public static void setLocation(Assignment assignment) throws DistributedStoreException { TabletStateStore store; if (assignment.tablet.isRootTablet()) { store = new ZooTabletStateStore(); } else { store = new MetaDataStateStore(); } store.setLocations(Collections.singletonList(assignment)); }
@Override public void setFutureLocations(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); } store.put(Constants.ZROOT_TABLET_FUTURE_LOCATION, value.getBytes(UTF_8)); }
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); } }
protected static TabletStateStore getStoreForTablet(KeyExtent extent, AccumuloServerContext context) throws DistributedStoreException { if (extent.isRootTablet()) { return new ZooTabletStateStore(); } else if (extent.isMeta()) { return new RootTabletStateStore(context); } else { return new MetaDataStateStore(context); } } }
@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"); }
zooScanner = new ZooTabletStateStore().iterator(); } catch (DistributedStoreException e) { throw new AccumuloException(e);