Skip to content

Commit

Permalink
refactor: bad smell
Browse files Browse the repository at this point in the history
  • Loading branch information
shihuili1218 committed Jan 27, 2024
1 parent 9920166 commit dc187d2
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*
* @author 释慧利
*/
@Deprecated()
public interface Lifecycle<O> {
public interface Role<O> {

/**
* Bean init.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import java.io.Serializable;

import com.ofcoder.klein.common.Lifecycle;
import com.ofcoder.klein.consensus.facade.config.ConsensusProp;
import com.ofcoder.klein.consensus.facade.sm.SM;
import com.ofcoder.klein.spi.SPI;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class PaxosConsensus implements Consensus {
private final RpcClient client;
private final Proxy proxy;

public PaxosConsensus(ConsensusProp prop) {
public PaxosConsensus(final ConsensusProp prop) {
this.prop = prop;
this.client = ExtensionLoader.getExtensionLoader(RpcClient.class).getJoin();
ExtensionLoader.getExtensionLoader(Nwr.class).register(this.prop.getNwr());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package com.ofcoder.klein.consensus.paxos.core;

import com.ofcoder.klein.common.Lifecycle;
import com.ofcoder.klein.common.Role;
import com.ofcoder.klein.consensus.facade.config.ConsensusProp;
import com.ofcoder.klein.consensus.paxos.rpc.vo.AcceptReq;
import com.ofcoder.klein.consensus.paxos.rpc.vo.AcceptRes;
Expand All @@ -28,7 +28,7 @@
*
* @author 释慧利
*/
public interface Acceptor extends Lifecycle<ConsensusProp> {
public interface Acceptor extends Role<ConsensusProp> {
/**
* Process the Accept message from Proposer.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import com.ofcoder.klein.common.Lifecycle;
import com.ofcoder.klein.common.Role;
import com.ofcoder.klein.consensus.facade.config.ConsensusProp;
import com.ofcoder.klein.consensus.facade.sm.SM;
import com.ofcoder.klein.consensus.paxos.rpc.vo.ConfirmReq;
Expand All @@ -38,7 +38,7 @@
*
* @author 释慧利
*/
public interface Learner extends Lifecycle<ConsensusProp> {
public interface Learner extends Role<ConsensusProp> {

/**
* generate and save snapshot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.Set;

import com.ofcoder.klein.common.Lifecycle;
import com.ofcoder.klein.common.Role;
import com.ofcoder.klein.consensus.facade.config.ConsensusProp;
import com.ofcoder.klein.consensus.paxos.rpc.vo.NewMasterReq;
import com.ofcoder.klein.consensus.paxos.rpc.vo.NewMasterRes;
Expand All @@ -30,7 +30,7 @@
*
* @author 释慧利
*/
public interface Master extends Lifecycle<ConsensusProp> {
public interface Master extends Role<ConsensusProp> {
byte ADD = 0;
byte REMOVE = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.List;

import com.ofcoder.klein.common.Holder;
import com.ofcoder.klein.common.Lifecycle;
import com.ofcoder.klein.common.Role;
import com.ofcoder.klein.consensus.facade.config.ConsensusProp;
import com.ofcoder.klein.consensus.paxos.Proposal;
import com.ofcoder.klein.consensus.paxos.core.sm.PaxosMemberConfiguration;
Expand All @@ -29,7 +29,7 @@
*
* @author 释慧利
*/
public interface Proposer extends Lifecycle<ConsensusProp> {
public interface Proposer extends Role<ConsensusProp> {
/**
* Propose proposal.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ofcoder.klein.common.Lifecycle;
import com.ofcoder.klein.common.serialization.Hessian2Util;
import com.ofcoder.klein.rpc.facade.config.RpcProp;
import com.ofcoder.klein.spi.SPI;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public T getDefaultJoin() {
* get join use global.
*
* @param name join name
* @param args construction parameters
* @return join
*/
public T register(final String name, final Object... args) {
Expand Down Expand Up @@ -257,8 +258,8 @@ private Holder<T> createExtension(final String name, final Object... args) {
Constructor<?> constructor = aClass.getConstructor(paramTypes);
joinInstances.putIfAbsent(aClass, constructor.newInstance(args));
o = joinInstances.get(aClass);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
NoSuchMethodException e) {
} catch (InstantiationException | IllegalAccessException | InvocationTargetException
| NoSuchMethodException e) {
throw new IllegalStateException("Extension instance(name: " + name + ", class: "
+ aClass + ") could not be instantiated: " + e.getMessage(), e);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import com.ofcoder.klein.common.Lifecycle;
import com.ofcoder.klein.spi.SPI;
import com.ofcoder.klein.storage.facade.config.StorageProp;

/**
* Manage logs generated by the consensus system.
Expand Down

0 comments on commit dc187d2

Please sign in to comment.