szetszwo commented on code in PR #10252: URL: https://github.com/apache/ozone/pull/10252#discussion_r3255456394
########## hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/SequenceIdStateManagerInvoker.java: ########## @@ -0,0 +1,111 @@ +/* + * 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 + * + * http://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.hadoop.hdds.scm.ha.invoker; + +import java.io.IOException; +import org.apache.hadoop.hdds.scm.exceptions.SCMException; +import org.apache.hadoop.hdds.scm.ha.SCMRatisResponse; +import org.apache.hadoop.hdds.scm.ha.SCMRatisServer; +import org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator.StateManager; +import org.apache.hadoop.hdds.utils.db.Table; +import org.apache.ratis.protocol.Message; + +/** Code generated for {@link StateManager}. Do not modify. */ +public class SequenceIdStateManagerInvoker extends ScmInvoker<StateManager> { Review Comment: Let's use the full outer class name `SequenceIdGeneratorStateManagerInvoker`. We should also fix ScmInvokerCodeGenerator. ########## hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/SequenceIdStateManagerInvoker.java: ########## @@ -0,0 +1,111 @@ +/* + * 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 + * + * http://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.hadoop.hdds.scm.ha.invoker; + +import java.io.IOException; +import org.apache.hadoop.hdds.scm.exceptions.SCMException; +import org.apache.hadoop.hdds.scm.ha.SCMRatisResponse; +import org.apache.hadoop.hdds.scm.ha.SCMRatisServer; +import org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator.StateManager; +import org.apache.hadoop.hdds.utils.db.Table; +import org.apache.ratis.protocol.Message; + +/** Code generated for {@link StateManager}. Do not modify. */ +public class SequenceIdStateManagerInvoker extends ScmInvoker<StateManager> { + enum ReplicateMethod implements NameAndParameterTypes { + allocateBatch(new Class<?>[][] { + null, + null, + null, + new Class<?>[] {String.class, Long.class, Long.class} + }); + + private final Class<?>[][] parameterTypes; + + ReplicateMethod(Class<?>[][] parameterTypes) { + this.parameterTypes = parameterTypes; + } + + @Override + public Class<?>[] getParameterTypes(int numArgs) { + return parameterTypes[numArgs]; + } + } + + public SequenceIdStateManagerInvoker(StateManager impl, SCMRatisServer ratis) { + super(impl, SequenceIdStateManagerInvoker::newProxy, ratis); + } + + @Override + public Class<StateManager> getApi() { + return StateManager.class; + } + + static StateManager newProxy(ScmInvoker<StateManager> invoker) { + return new StateManager() { + + @Override + public Boolean allocateBatch(String arg0, Long arg1, Long arg2) throws SCMException { + final Object[] args = {arg0, arg1, arg2}; + return (Boolean) invoker.invokeReplicateDirect(ReplicateMethod.allocateBatch, args); + } + + @Override + public Long getLastId(String arg0) { + return invoker.getImpl().getLastId(arg0); + } + + @Override + public void reinitialize(Table<String, Long> arg0) throws IOException { Review Comment: Please don't manually add the generic types for the generated code. It is hard to maintain. It is unfortunate that we cannot get generic types from reflection since they are compile time information but not runtime information. ########## hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/invoker/SequenceIdStateManagerInvoker.java: ########## @@ -0,0 +1,111 @@ +/* + * 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 + * + * http://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.hadoop.hdds.scm.ha.invoker; + +import java.io.IOException; +import org.apache.hadoop.hdds.scm.exceptions.SCMException; +import org.apache.hadoop.hdds.scm.ha.SCMRatisResponse; +import org.apache.hadoop.hdds.scm.ha.SCMRatisServer; +import org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator.StateManager; +import org.apache.hadoop.hdds.utils.db.Table; +import org.apache.ratis.protocol.Message; + +/** Code generated for {@link StateManager}. Do not modify. */ +public class SequenceIdStateManagerInvoker extends ScmInvoker<StateManager> { + enum ReplicateMethod implements NameAndParameterTypes { + allocateBatch(new Class<?>[][] { + null, + null, + null, + new Class<?>[] {String.class, Long.class, Long.class} + }); + + private final Class<?>[][] parameterTypes; + + ReplicateMethod(Class<?>[][] parameterTypes) { + this.parameterTypes = parameterTypes; + } + + @Override + public Class<?>[] getParameterTypes(int numArgs) { + return parameterTypes[numArgs]; + } + } + + public SequenceIdStateManagerInvoker(StateManager impl, SCMRatisServer ratis) { + super(impl, SequenceIdStateManagerInvoker::newProxy, ratis); + } + + @Override + public Class<StateManager> getApi() { + return StateManager.class; + } + + static StateManager newProxy(ScmInvoker<StateManager> invoker) { + return new StateManager() { + + @Override + public Boolean allocateBatch(String arg0, Long arg1, Long arg2) throws SCMException { + final Object[] args = {arg0, arg1, arg2}; + return (Boolean) invoker.invokeReplicateDirect(ReplicateMethod.allocateBatch, args); Review Comment: We should fix ScmInvokerCodeGenerator for the casting. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
