You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/09/28 12:48:57 UTC

[GitHub] [accumulo] milleruntime opened a new pull request, #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

milleruntime opened a new pull request, #2976:
URL: https://github.com/apache/accumulo/pull/2976

   * The ReadOnlyStore class is unnecessary and prone to bugs. The way the Fate code was originally written used the interface ReadOnlyTStore to prevent access to the "write" methods in TStore.
   * Fixes #2973


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] milleruntime commented on a diff in pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
milleruntime commented on code in PR #2976:
URL: https://github.com/apache/accumulo/pull/2976#discussion_r984567810


##########
core/src/main/java/org/apache/accumulo/fate/ReadOnlyStore.java:
##########
@@ -1,124 +0,0 @@
-/*
- * 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.fate;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.Serializable;
-import java.util.EnumSet;
-import java.util.List;
-
-/**
- * This store decorates a TStore to make sure it can not be modified.
- *
- * Unlike relying directly on the ReadOnlyTStore interface, this class will not allow subsequent
- * users to cast back to a mutable TStore successfully.
- */
-public class ReadOnlyStore<T> implements ReadOnlyTStore<T> {
-
-  private final ZooStore<T> store;
-
-  /**
-   * @param store
-   *          may not be null
-   */
-  public ReadOnlyStore(ZooStore<T> store) {
-    requireNonNull(store);
-    this.store = store;
-  }
-
-  @Override
-  public long reserve() {
-    return store.reserve();
-  }
-
-  @Override
-  public void reserve(long tid) {
-    store.reserve(tid);
-  }
-
-  @Override
-  public void unreserve(long tid, long deferTime) {
-    store.unreserve(tid, deferTime);
-  }
-
-  /**
-   * Decorates a Repo to make sure it is treated as a ReadOnlyRepo.
-   *
-   * Similar to ReadOnlyStore, won't allow subsequent user to cast a ReadOnlyRepo back to a mutable
-   * Repo.
-   */
-  protected static class ReadOnlyRepoWrapper<X> implements ReadOnlyRepo<X> {
-    private final Repo<X> repo;
-
-    /**
-     * @param repo
-     *          may not be null
-     */
-    public ReadOnlyRepoWrapper(Repo<X> repo) {
-      requireNonNull(repo);
-      this.repo = repo;
-    }
-
-    @Override
-    public long isReady(long tid, X environment) throws Exception {
-      return repo.isReady(tid, environment);
-    }
-
-    @Override
-    public String getName() {
-      return repo.getName();
-    }
-  }
-
-  @Override
-  public ReadOnlyRepo<T> top(long tid) {
-    return new ReadOnlyRepoWrapper<>(store.top(tid));
-  }

Review Comment:
   I feel pretty confident that we are losing very little. I am going to merge this, cause it fixes Admin so I can push up another fix to Admin.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] milleruntime commented on a diff in pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
milleruntime commented on code in PR #2976:
URL: https://github.com/apache/accumulo/pull/2976#discussion_r982452913


##########
server/base/src/main/java/org/apache/accumulo/server/util/Admin.java:
##########
@@ -795,25 +794,22 @@ private void executeFateOpsCommand(ServerContext context, FateOpsCommand fateOps
       }
     }
 
-    ReadOnlyStore<Admin> readOnlyStore = new ReadOnlyStore<>(zs);
-
     if (fateOpsCommand.print) {
       final Set<Long> sortedTxs = new TreeSet<>();
       fateOpsCommand.txList.forEach(s -> sortedTxs.add(parseTidFromUserInput(s)));
       if (!fateOpsCommand.txList.isEmpty()) {
         EnumSet<ReadOnlyTStore.TStatus> statusFilter =
             getCmdLineStatusFilters(fateOpsCommand.states);
-        admin.print(readOnlyStore, zk, zTableLocksPath, new Formatter(System.out), sortedTxs,
-            statusFilter);
+        admin.print(zs, zk, zTableLocksPath, new Formatter(System.out), sortedTxs, statusFilter);

Review Comment:
   No need. The call to the method takes care of that for you.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] milleruntime commented on a diff in pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
milleruntime commented on code in PR #2976:
URL: https://github.com/apache/accumulo/pull/2976#discussion_r982723757


##########
core/src/main/java/org/apache/accumulo/fate/ReadOnlyStore.java:
##########
@@ -1,124 +0,0 @@
-/*
- * 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.fate;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.Serializable;
-import java.util.EnumSet;
-import java.util.List;
-
-/**
- * This store decorates a TStore to make sure it can not be modified.
- *
- * Unlike relying directly on the ReadOnlyTStore interface, this class will not allow subsequent
- * users to cast back to a mutable TStore successfully.
- */
-public class ReadOnlyStore<T> implements ReadOnlyTStore<T> {
-
-  private final ZooStore<T> store;
-
-  /**
-   * @param store
-   *          may not be null
-   */
-  public ReadOnlyStore(ZooStore<T> store) {
-    requireNonNull(store);
-    this.store = store;
-  }
-
-  @Override
-  public long reserve() {
-    return store.reserve();
-  }
-
-  @Override
-  public void reserve(long tid) {
-    store.reserve(tid);
-  }
-
-  @Override
-  public void unreserve(long tid, long deferTime) {
-    store.unreserve(tid, deferTime);
-  }
-
-  /**
-   * Decorates a Repo to make sure it is treated as a ReadOnlyRepo.
-   *
-   * Similar to ReadOnlyStore, won't allow subsequent user to cast a ReadOnlyRepo back to a mutable
-   * Repo.
-   */
-  protected static class ReadOnlyRepoWrapper<X> implements ReadOnlyRepo<X> {
-    private final Repo<X> repo;
-
-    /**
-     * @param repo
-     *          may not be null
-     */
-    public ReadOnlyRepoWrapper(Repo<X> repo) {
-      requireNonNull(repo);
-      this.repo = repo;
-    }
-
-    @Override
-    public long isReady(long tid, X environment) throws Exception {
-      return repo.isReady(tid, environment);
-    }
-
-    @Override
-    public String getName() {
-      return repo.getName();
-    }
-  }
-
-  @Override
-  public ReadOnlyRepo<T> top(long tid) {
-    return new ReadOnlyRepoWrapper<>(store.top(tid));
-  }

Review Comment:
   That would work to fix the NPE errors but I don't think we need the extra layer of abstraction with the ReadOnlyStore class.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] dlmarion commented on a diff in pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
dlmarion commented on code in PR #2976:
URL: https://github.com/apache/accumulo/pull/2976#discussion_r982442544


##########
server/base/src/main/java/org/apache/accumulo/server/util/Admin.java:
##########
@@ -795,25 +794,22 @@ private void executeFateOpsCommand(ServerContext context, FateOpsCommand fateOps
       }
     }
 
-    ReadOnlyStore<Admin> readOnlyStore = new ReadOnlyStore<>(zs);
-
     if (fateOpsCommand.print) {
       final Set<Long> sortedTxs = new TreeSet<>();
       fateOpsCommand.txList.forEach(s -> sortedTxs.add(parseTidFromUserInput(s)));
       if (!fateOpsCommand.txList.isEmpty()) {
         EnumSet<ReadOnlyTStore.TStatus> statusFilter =
             getCmdLineStatusFilters(fateOpsCommand.states);
-        admin.print(readOnlyStore, zk, zTableLocksPath, new Formatter(System.out), sortedTxs,
-            statusFilter);
+        admin.print(zs, zk, zTableLocksPath, new Formatter(System.out), sortedTxs, statusFilter);

Review Comment:
   ```suggestion
           admin.print((ReadOnlyTStore) zs, zk, zTableLocksPath, new Formatter(System.out), sortedTxs, statusFilter);
   ```
   would it make sense to cast here?



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii commented on a diff in pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on code in PR #2976:
URL: https://github.com/apache/accumulo/pull/2976#discussion_r983701260


##########
core/src/main/java/org/apache/accumulo/fate/ReadOnlyStore.java:
##########
@@ -1,124 +0,0 @@
-/*
- * 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.fate;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.Serializable;
-import java.util.EnumSet;
-import java.util.List;
-
-/**
- * This store decorates a TStore to make sure it can not be modified.
- *
- * Unlike relying directly on the ReadOnlyTStore interface, this class will not allow subsequent
- * users to cast back to a mutable TStore successfully.
- */
-public class ReadOnlyStore<T> implements ReadOnlyTStore<T> {
-
-  private final ZooStore<T> store;
-
-  /**
-   * @param store
-   *          may not be null
-   */
-  public ReadOnlyStore(ZooStore<T> store) {
-    requireNonNull(store);
-    this.store = store;
-  }
-
-  @Override
-  public long reserve() {
-    return store.reserve();
-  }
-
-  @Override
-  public void reserve(long tid) {
-    store.reserve(tid);
-  }
-
-  @Override
-  public void unreserve(long tid, long deferTime) {
-    store.unreserve(tid, deferTime);
-  }
-
-  /**
-   * Decorates a Repo to make sure it is treated as a ReadOnlyRepo.
-   *
-   * Similar to ReadOnlyStore, won't allow subsequent user to cast a ReadOnlyRepo back to a mutable
-   * Repo.
-   */
-  protected static class ReadOnlyRepoWrapper<X> implements ReadOnlyRepo<X> {
-    private final Repo<X> repo;
-
-    /**
-     * @param repo
-     *          may not be null
-     */
-    public ReadOnlyRepoWrapper(Repo<X> repo) {
-      requireNonNull(repo);
-      this.repo = repo;
-    }
-
-    @Override
-    public long isReady(long tid, X environment) throws Exception {
-      return repo.isReady(tid, environment);
-    }
-
-    @Override
-    public String getName() {
-      return repo.getName();
-    }
-  }
-
-  @Override
-  public ReadOnlyRepo<T> top(long tid) {
-    return new ReadOnlyRepoWrapper<>(store.top(tid));
-  }

Review Comment:
   > That would work to fix the NPE errors but I don't think we need the extra layer of abstraction with the ReadOnlyStore class.
   
   Okay, that's fine too. As I said, I wasn't sure what it was protecting or what we'd lose. If we don't need it, I'm happy to get rid of it.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] milleruntime commented on pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
milleruntime commented on PR #2976:
URL: https://github.com/apache/accumulo/pull/2976#issuecomment-1262445267

   @keith-turner any thoughts on this change?


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] milleruntime merged pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
milleruntime merged PR #2976:
URL: https://github.com/apache/accumulo/pull/2976


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [accumulo] ctubbsii commented on a diff in pull request #2976: Drop ReadOnlyStore in favor of polymorphism in FaTE

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on code in PR #2976:
URL: https://github.com/apache/accumulo/pull/2976#discussion_r982690259


##########
core/src/main/java/org/apache/accumulo/fate/ReadOnlyStore.java:
##########
@@ -1,124 +0,0 @@
-/*
- * 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.fate;
-
-import static java.util.Objects.requireNonNull;
-
-import java.io.Serializable;
-import java.util.EnumSet;
-import java.util.List;
-
-/**
- * This store decorates a TStore to make sure it can not be modified.
- *
- * Unlike relying directly on the ReadOnlyTStore interface, this class will not allow subsequent
- * users to cast back to a mutable TStore successfully.
- */
-public class ReadOnlyStore<T> implements ReadOnlyTStore<T> {
-
-  private final ZooStore<T> store;
-
-  /**
-   * @param store
-   *          may not be null
-   */
-  public ReadOnlyStore(ZooStore<T> store) {
-    requireNonNull(store);
-    this.store = store;
-  }
-
-  @Override
-  public long reserve() {
-    return store.reserve();
-  }
-
-  @Override
-  public void reserve(long tid) {
-    store.reserve(tid);
-  }
-
-  @Override
-  public void unreserve(long tid, long deferTime) {
-    store.unreserve(tid, deferTime);
-  }
-
-  /**
-   * Decorates a Repo to make sure it is treated as a ReadOnlyRepo.
-   *
-   * Similar to ReadOnlyStore, won't allow subsequent user to cast a ReadOnlyRepo back to a mutable
-   * Repo.
-   */
-  protected static class ReadOnlyRepoWrapper<X> implements ReadOnlyRepo<X> {
-    private final Repo<X> repo;
-
-    /**
-     * @param repo
-     *          may not be null
-     */
-    public ReadOnlyRepoWrapper(Repo<X> repo) {
-      requireNonNull(repo);
-      this.repo = repo;
-    }
-
-    @Override
-    public long isReady(long tid, X environment) throws Exception {
-      return repo.isReady(tid, environment);
-    }
-
-    @Override
-    public String getName() {
-      return repo.getName();
-    }
-  }
-
-  @Override
-  public ReadOnlyRepo<T> top(long tid) {
-    return new ReadOnlyRepoWrapper<>(store.top(tid));
-  }

Review Comment:
   I'm not sure what protections we're losing by removing this interface... but we could easily fix any NPE errors as a result of attempting to wrap `store.top(tid)` when it returns null by doing:
   
   ```java
     public ReadOnlyRepo<T> top(long tid) {
       var top = store.top(tid);
       return top == null ? null : new ReadOnlyRepoWrapper<>(top);
     }
   ```
   
   It might be safer to do this than to remove this interface entirely.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org