Skip to content

热点数据服务发现的实现 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

71 changes: 0 additions & 71 deletions core-swift/src/main/java/com/ware/swift/core/CoreSwiftManager.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.ware.swift.core;

import com.ware.swift.core.inter.ICoreSwiftManager;

import java.util.Set;

/**
* delegate the core swift manager
*/
public final class CoreSwiftManagerDelegate implements ICoreSwiftManager {

private static ICoreSwiftManager coreSwiftManager;

static {
try {
Set<ICoreSwiftManager> wareSwiftManagers = WareCoreSwiftPluginLoader.load(ICoreSwiftManager.class,
CoreSwiftManagerImpl.class.getClassLoader());

boolean isLoad = false;
if (wareSwiftManagers != null && wareSwiftManagers.size() > 0) {
coreSwiftManager = wareSwiftManagers.iterator().next();
isLoad = true;
}

if (!isLoad) {
coreSwiftManager = new CoreSwiftManagerImpl();
}
} catch (Exception e) {
e.printStackTrace();
}
}

private final static CoreSwiftManagerDelegate CORE_SWIFT_MANAGER = new CoreSwiftManagerDelegate();

private CoreSwiftManagerDelegate() {
}

public static CoreSwiftManagerDelegate getInstance() {
return CORE_SWIFT_MANAGER;
}

public void init(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {

coreSwiftManager.init(wareSwiftGlobalContext);
}

public void startBefore(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {
coreSwiftManager.startBefore(wareSwiftGlobalContext);
}

public void start(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {
coreSwiftManager.start(wareSwiftGlobalContext);
}

public void startAfter(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {
coreSwiftManager.startAfter(wareSwiftGlobalContext);
}

public void shutdown(NodeInformation nodeInformation) {
coreSwiftManager.shutdown(nodeInformation);
}

public void getAllNodeInformation() {
coreSwiftManager.getAllNodeInformation();
}

public void getClusterNodeInformation(String clusterName) {
coreSwiftManager.getClusterNodeInformation(clusterName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.ware.swift.core;

import com.ware.swift.core.inter.ICoreSwiftManager;
import com.ware.swift.core.remoting.RemotingManager;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import io.netty.util.internal.logging.JdkLoggerFactory;

import static com.ware.swift.core.WareCoreSwiftGlobalContext.RAFT_CONTEXT_ATTR_KEY_CONFIG;
import static com.ware.swift.core.WareCoreSwiftGlobalContext.RAFT_CONTEXT_ATTR_KEY_CONFIG_PATH;

/**
*
*/
public class CoreSwiftManagerImpl implements ICoreSwiftManager {

private InternalLogger logger = InternalLoggerFactory
.getInstance(CoreSwiftManagerImpl.class);

public void init(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {
startBefore(wareSwiftGlobalContext);
start(wareSwiftGlobalContext);
startAfter(wareSwiftGlobalContext);
}

/**
* @param wareSwiftGlobalContext
*/
public void startBefore(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {
InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE);
String configPath = wareSwiftGlobalContext.getAttribute(
RAFT_CONTEXT_ATTR_KEY_CONFIG_PATH, "ware-swift.properties");
try {
WareCoreSwiftConfig wareSwiftConfig = WareCoreSwiftConfigManager.initRaftConfig(configPath,
this.getClass().getClassLoader());
RemotingManager.getRemotingManager().init(wareSwiftConfig);
wareSwiftGlobalContext.putAttribute(RAFT_CONTEXT_ATTR_KEY_CONFIG, wareSwiftConfig);
} catch (Exception e) {
logger.error(WareCoreSwiftExceptionCode.getConfigInitializerErrorMessage(
" init wareSwift cause an exception with " + configPath), e);
}
}

/**
* @param wareSwiftGlobalContext
*/
public void start(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {

RemotingManager.getRemotingManager().startLeaderElection(wareSwiftGlobalContext);
}

/**
* @param wareSwiftGlobalContext
*/
public void startAfter(WareCoreSwiftGlobalContext wareSwiftGlobalContext) {

}

/**
* @param nodeInformation
*/
public void shutdown(NodeInformation nodeInformation) {

}

/**
*
*/
public void getAllNodeInformation() {

}

/**
* @param clusterName
*/
public void getClusterNodeInformation(String clusterName) {

}
}
12 changes: 12 additions & 0 deletions core-swift/src/main/java/com/ware/swift/core/IPluginAble.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ware.swift.core;

/**
*
*/
public interface IPluginAble {

/**
* @return
*/
String getPluginName();
}
9 changes: 0 additions & 9 deletions core-swift/src/main/java/com/ware/swift/core/IPluginable.java

This file was deleted.

Loading