Skip to content

Commit

Permalink
重构
Browse files Browse the repository at this point in the history
  • Loading branch information
闫逍旭 committed May 15, 2016
1 parent 278315f commit 5ae7b8a
Show file tree
Hide file tree
Showing 134 changed files with 699 additions and 473 deletions.
File renamed without changes.
7 changes: 4 additions & 3 deletions debug.sh → bin/debug.sh 100755 → 100644
@@ -1,14 +1,15 @@
#!/bin/sh #!/bin/sh


ENV=dev ENV=daily
base_dir=`pwd` cd `dirname $0`
cd ..


echo "start package project..." echo "start package project..."
mvn clean mvn clean
mvn package -P $ENV mvn package -P $ENV


echo "start tar mpush..." echo "start tar mpush..."
cd $base_dir/mpush-boot/target cd ./mpush-boot/target
tar -xzvf ./mpush-release.tar.gz tar -xzvf ./mpush-release.tar.gz


echo "start start mpush..." echo "start start mpush..."
Expand Down
0 pub-daily.py → bin/pub-daily.py 100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions bin/run.sh
@@ -0,0 +1,20 @@
#!/bin/sh

ENV=dev

cd `dirname $0`
cd ..

echo "start tar mpush..."
cd ./mpush-boot/target

rm -rf mpush
tar -xzvf ./mpush-release.tar.gz

echo "start start mpush..."

cd mpush
java \
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7998 \
-Dio.netty.leakDetectionLevel=advanced \
-jar boot.jar
23 changes: 23 additions & 0 deletions bin/start.sh
@@ -0,0 +1,23 @@
#!/bin/sh

ENV=dev

cd `dirname $0`
cd ..

echo "start package project..."
mvn clean
mvn package -P $ENV

echo "start tar mpush..."
cd ./mpush-boot/target
tar -xzvf ./mpush-release.tar.gz

echo "start start mpush..."
cd mpush
nohup java \
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7998 \
-Dio.netty.leakDetectionLevel=advanced \
-jar boot.jar >/dev/null 2>&1 &

echo "end start mpush..."
0 test.py → bin/test.py 100755 → 100644
File renamed without changes.
0 test.sh → bin/test.sh 100755 → 100644
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/Constants.java
Expand Up @@ -4,6 +4,8 @@


/** /**
* Created by ohun on 2015/12/23. * Created by ohun on 2015/12/23.
*
* @author ohun@live.cn
*/ */
public interface Constants { public interface Constants {
Charset UTF_8 = Charset.forName("UTF-8"); Charset UTF_8 = Charset.forName("UTF-8");
Expand Down
4 changes: 3 additions & 1 deletion mpush-api/src/main/java/com/mpush/api/Message.java
@@ -1,11 +1,13 @@
package com.mpush.api; package com.mpush.api;


import com.mpush.api.protocol.Packet;
import com.mpush.api.connection.Connection; import com.mpush.api.connection.Connection;
import com.mpush.api.protocol.Packet;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;


/** /**
* Created by ohun on 2015/12/22. * Created by ohun on 2015/12/22.
*
* @author ohun@live.cn
*/ */
public interface Message { public interface Message {


Expand Down
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/MessageHandler.java
Expand Up @@ -5,6 +5,8 @@


/** /**
* Created by ohun on 2015/12/22. * Created by ohun on 2015/12/22.
*
* @author ohun@live.cn
*/ */
public interface MessageHandler { public interface MessageHandler {
void handle(Packet packet, Connection connection); void handle(Packet packet, Connection connection);
Expand Down
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/PacketReceiver.java
Expand Up @@ -5,6 +5,8 @@


/** /**
* Created by ohun on 2015/12/22. * Created by ohun on 2015/12/22.
*
* @author ohun@live.cn
*/ */
public interface PacketReceiver { public interface PacketReceiver {
void onReceive(Packet packet, Connection connection); void onReceive(Packet packet, Connection connection);
Expand Down
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/PushSender.java
Expand Up @@ -4,6 +4,8 @@


/** /**
* Created by ohun on 2015/12/30. * Created by ohun on 2015/12/30.
*
* @author ohun@live.cn
*/ */
public interface PushSender { public interface PushSender {
void send(String content, Collection<String> userIds, Callback callback); void send(String content, Collection<String> userIds, Callback callback);
Expand Down
6 changes: 4 additions & 2 deletions mpush-api/src/main/java/com/mpush/api/Server.java
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/24. * Created by ohun on 2015/12/24.
*
* @author ohun@live.cn
*/ */
public interface Server { public interface Server {


Expand All @@ -14,8 +16,8 @@ public interface Server {
boolean isRunning(); boolean isRunning();


interface Listener { interface Listener {
void onSuccess(); void onSuccess(int port);


void onFailure(String message); void onFailure(Throwable cause);
} }
} }
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/connection/Cipher.java
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/28. * Created by ohun on 2015/12/28.
*
* @author ohun@live.cn
*/ */
public interface Cipher { public interface Cipher {


Expand Down
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/22. * Created by ohun on 2015/12/22.
*
* @author ohun@live.cn
*/ */
public final class SessionContext { public final class SessionContext {
public String osName; public String osName;
Expand Down
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/event/Event.java
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/29. * Created by ohun on 2015/12/29.
*
* @author ohun@live.cn
*/ */
public interface Event { public interface Event {
} }
Expand Up @@ -4,6 +4,8 @@


/** /**
* Created by ohun on 2015/12/29. * Created by ohun on 2015/12/29.
*
* @author ohun@live.cn
*/ */
public final class HandshakeEvent implements Event { public final class HandshakeEvent implements Event {
public final Connection connection; public final Connection connection;
Expand Down
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/29. * Created by ohun on 2015/12/29.
*
* @author ohun@live.cn
*/ */
public final class KickUserEvent implements Event { public final class KickUserEvent implements Event {
public final String userId; public final String userId;
Expand Down
Expand Up @@ -4,6 +4,8 @@


/** /**
* Created by ohun on 2016/1/4. * Created by ohun on 2016/1/4.
*
* @author ohun@live.cn
*/ */
public final class RouterChangeEvent implements Event { public final class RouterChangeEvent implements Event {
public final String userId; public final String userId;
Expand Down
Expand Up @@ -2,13 +2,15 @@


/** /**
* Created by ohun on 2015/12/23. * Created by ohun on 2015/12/23.
*
* @author ohun@live.cn
*/ */
public class CryptoException extends RuntimeException { public class CryptoException extends RuntimeException {

private static final long serialVersionUID = 368277451733324220L;


public CryptoException(String message) { private static final long serialVersionUID = 368277451733324220L;

public CryptoException(String message) {
super(message); super(message);
} }

} }
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/23. * Created by ohun on 2015/12/23.
*
* @author ohun@live.cn
*/ */
public class DecodeException extends RuntimeException { public class DecodeException extends RuntimeException {
public DecodeException(String message) { public DecodeException(String message) {
Expand Down
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/30. * Created by ohun on 2015/12/30.
*
* @author ohun@live.cn
*/ */
public class SendMessageException extends RuntimeException { public class SendMessageException extends RuntimeException {
} }
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/protocol/Packet.java
Expand Up @@ -6,6 +6,8 @@
/** /**
* Created by ohun on 2015/12/19. * Created by ohun on 2015/12/19.
* length(4)+cmd(1)+cc(2)+flags(1)+sessionId(4)+lrc(1)+body(n) * length(4)+cmd(1)+cc(2)+flags(1)+sessionId(4)+lrc(1)+body(n)
*
* @author ohun@live.cn
*/ */
public final class Packet { public final class Packet {
public static final int HEADER_LEN = 13; public static final int HEADER_LEN = 13;
Expand Down
Expand Up @@ -4,6 +4,8 @@


/** /**
* Created by ohun on 2015/12/23. * Created by ohun on 2015/12/23.
*
* @author ohun@live.cn
*/ */
public final class ClientLocation { public final class ClientLocation {


Expand Down
2 changes: 2 additions & 0 deletions mpush-api/src/main/java/com/mpush/api/router/Router.java
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/23. * Created by ohun on 2015/12/23.
*
* @author ohun@live.cn
*/ */
public interface Router<T> { public interface Router<T> {


Expand Down
Expand Up @@ -2,6 +2,8 @@


/** /**
* Created by ohun on 2015/12/23. * Created by ohun on 2015/12/23.
*
* @author ohun@live.cn
*/ */
public interface RouterManager<R extends Router> { public interface RouterManager<R extends Router> {


Expand Down
5 changes: 2 additions & 3 deletions mpush-boot/pom.xml
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>${mpush.groupId}</groupId> <groupId>${mpush.groupId}</groupId>
<artifactId>mpush-boot</artifactId> <artifactId>mpush-boot</artifactId>
<version>${mpush-cs-version}</version> <version>${mpush-boot-version}</version>
<name>mpush-boot</name> <name>mpush-boot</name>
<packaging>jar</packaging> <packaging>jar</packaging>


Expand All @@ -34,7 +34,7 @@
<build> <build>
<finalName>boot</finalName> <finalName>boot</finalName>
<filters> <filters>
<filter>../conf-${deploy.env}.properties</filter> <filter>../conf/conf-${deploy.env}.properties</filter>
</filters> </filters>
<resources> <resources>
<resource> <resource>
Expand Down Expand Up @@ -89,5 +89,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

</project> </project>
4 changes: 4 additions & 0 deletions mpush-boot/src/main/java/com/mpush/Main.java
@@ -1,8 +1,11 @@
package com.mpush; package com.mpush;


import com.mpush.tools.ConsoleLog;

public class Main { public class Main {


public static void main(String[] args) { public static void main(String[] args) {
ConsoleLog.i("launch app...");
ServerLauncher launcher = new ServerLauncher(); ServerLauncher launcher = new ServerLauncher();
launcher.start(); launcher.start();
addHook(launcher); addHook(launcher);
Expand All @@ -12,6 +15,7 @@ private static void addHook(final ServerLauncher serverBoot) {
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() { public void run() {
serverBoot.stop(); serverBoot.stop();
ConsoleLog.i("jvm exit all server stopped...");
} }
}); });
} }
Expand Down
15 changes: 11 additions & 4 deletions mpush-boot/src/main/java/com/mpush/ServerLauncher.java
@@ -1,14 +1,19 @@
package com.mpush; package com.mpush;




import com.mpush.boot.*;
import com.mpush.zk.ZKServerNode;
import com.mpush.api.Server; import com.mpush.api.Server;
import com.mpush.boot.*;
import com.mpush.core.server.AdminServer; import com.mpush.core.server.AdminServer;
import com.mpush.core.server.ConnectionServer; import com.mpush.core.server.ConnectionServer;
import com.mpush.core.server.GatewayServer; import com.mpush.core.server.GatewayServer;
import com.mpush.tools.config.ConfigCenter; import com.mpush.tools.config.ConfigCenter;
import com.mpush.zk.ZKServerNode;


/**
* Created by yxx on 2016/5/14.
*
* @author ohun@live.cn
*/
public class ServerLauncher { public class ServerLauncher {
private final ZKServerNode csNode = ZKServerNode.csNode(); private final ZKServerNode csNode = ZKServerNode.csNode();


Expand All @@ -18,7 +23,7 @@ public class ServerLauncher {


private final Server gatewayServer = new GatewayServer(gsNode.getPort()); private final Server gatewayServer = new GatewayServer(gsNode.getPort());


private final Server adminServer = new AdminServer(ConfigCenter.holder.adminPort()); private final Server adminServer = new AdminServer(ConfigCenter.I.adminPort());




public void start() { public void start() {
Expand All @@ -29,7 +34,9 @@ public void start() {
.setNext(new ServerBoot(connectServer, csNode)) .setNext(new ServerBoot(connectServer, csNode))
.setNext(new ServerBoot(gatewayServer, gsNode)) .setNext(new ServerBoot(gatewayServer, gsNode))
.setNext(new ServerBoot(adminServer, null)) .setNext(new ServerBoot(adminServer, null))
.setNext(new EndBoot()); .setNext(new HttpProxyBoot())
.setNext(new MonitorBoot())
.setNext(new LastBoot());
chain.run(); chain.run();
} }


Expand Down
3 changes: 3 additions & 0 deletions mpush-boot/src/main/java/com/mpush/boot/BootChain.java
@@ -1,5 +1,7 @@
package com.mpush.boot; package com.mpush.boot;


import com.mpush.tools.ConsoleLog;

/** /**
* Created by yxx on 2016/5/15. * Created by yxx on 2016/5/15.
* *
Expand All @@ -20,6 +22,7 @@ private BootJob first() {
return new BootJob() { return new BootJob() {
@Override @Override
public void run() { public void run() {
ConsoleLog.i("begin run boot chain...");
next(); next();
} }
}; };
Expand Down
3 changes: 3 additions & 0 deletions mpush-boot/src/main/java/com/mpush/boot/BootJob.java
@@ -1,5 +1,7 @@
package com.mpush.boot; package com.mpush.boot;


import com.mpush.tools.ConsoleLog;

/** /**
* Created by yxx on 2016/5/14. * Created by yxx on 2016/5/14.
* *
Expand All @@ -12,6 +14,7 @@ public abstract class BootJob {


public void next() { public void next() {
if (next != null) { if (next != null) {
ConsoleLog.i("run next boot [" + next.getClass().getSimpleName() + "]");
next.run(); next.run();
} }
} }
Expand Down

0 comments on commit 5ae7b8a

Please sign in to comment.