keith-turner commented on code in PR #5247: URL: https://github.com/apache/accumulo/pull/5247#discussion_r1913415773
########## server/base/src/main/java/org/apache/accumulo/server/metadata/iterators/TabletMetadataCheckIterator.java: ########## @@ -0,0 +1,191 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.accumulo.server.metadata.iterators; + +import static org.apache.accumulo.core.util.LazySingletons.GSON; +import static org.apache.accumulo.server.metadata.iterators.ColumnFamilyTransformationIterator.getTabletRow; + +import java.io.IOException; +import java.util.Collection; +import java.util.EnumSet; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import org.apache.accumulo.core.classloader.ClassLoaderUtil; +import org.apache.accumulo.core.client.IteratorSetting; +import org.apache.accumulo.core.data.ByteSequence; +import org.apache.accumulo.core.data.Condition; +import org.apache.accumulo.core.data.Key; +import org.apache.accumulo.core.data.Range; +import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.dataImpl.KeyExtent; +import org.apache.accumulo.core.iterators.IteratorAdapter; +import org.apache.accumulo.core.iterators.IteratorEnvironment; +import org.apache.accumulo.core.iterators.SortedKeyValueIterator; +import org.apache.accumulo.core.metadata.schema.TabletMetadata; +import org.apache.accumulo.core.metadata.schema.TabletMetadataCheck; +import org.apache.accumulo.server.metadata.ConditionalTabletMutatorImpl; +import org.apache.hadoop.io.Text; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + +public class TabletMetadataCheckIterator implements SortedKeyValueIterator<Key,Value> { + + private static final Logger log = LoggerFactory.getLogger(TabletMetadataCheckIterator.class); + + private TabletMetadataCheck check; + private KeyExtent expectedExtent; + + private Key startKey; + private Value topValue; + private SortedKeyValueIterator<Key,Value> source; + + private static final String CHECK_CLASS_KEY = "checkClass"; + private static final String CHECK_DATA_KEY = "checkData"; + private static final String EXTENT_KEY = "checkExtent"; + private static final String SUCCESS = "success"; + + @Override + public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, + IteratorEnvironment env) throws IOException { + Preconditions.checkState(check == null && expectedExtent == null && startKey == null); + try { + String className = Objects.requireNonNull(options.get(CHECK_CLASS_KEY)); + String checkData = Objects.requireNonNull(options.get(CHECK_DATA_KEY)); + log.trace("Instantiating class {} using {}", className, checkData); + Class<? extends TabletMetadataCheck> clazz = + ClassLoaderUtil.loadClass(null, className, TabletMetadataCheck.class); + check = GSON.get().fromJson(checkData, clazz); + expectedExtent = KeyExtent.fromBase64(options.get(EXTENT_KEY)); + this.source = source; + } catch (ReflectiveOperationException e) { + throw new IllegalStateException(e); Review Comment: It depends on if the existing exception messages include the class name. Could add the class name to the IllegalStateException to be sure. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
