wildfire chat server source initial submit

This commit is contained in:
heavyrain2012
2019-03-16 17:04:23 +08:00
parent e59217bd10
commit cab3ca0916
1466 changed files with 528862 additions and 15919 deletions
@@ -0,0 +1,34 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.server;
import win.liyufan.im.Utility;
import java.util.Base64;
public class MechineCode {
public static void main(String[] args) throws Exception {
for (String arg: args
) {
System.out.println(arg);
}
if (args.length != 2) {
System.out.println("Usage: ip port");
System.exit(-1);
}
String mac = Utility.getMacAddress();
mac += "|";
mac += args[0];
mac += "|";
mac += args[1];
mac = Base64.getEncoder().encodeToString(mac.getBytes());
System.out.println(mac);
}
}
@@ -0,0 +1,17 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.server;
import java.io.IOException;
public class Server {
public static void main(String[] args) throws IOException {
io.moquette.server.Server.start(args);
}
}
@@ -0,0 +1,48 @@
/*
* This file is part of the Wildfire Chat package.
* (c) Heavyrain2012 <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
package cn.wildfirechat.server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
public class ThreadPoolExecutorWrapper {
private static final Logger LOG = LoggerFactory.getLogger(ThreadPoolExecutorWrapper.class);
private final ScheduledExecutorService executor;
private final int count;
private final AtomicInteger runCounter;
private final String name;
public ThreadPoolExecutorWrapper(ScheduledExecutorService executor, int count, String name) {
this.executor = executor;
this.count = count;
this.runCounter = new AtomicInteger();
this.name = name;
}
public void execute(Runnable task) {
int startCount = runCounter.incrementAndGet();
LOG.info("Submit task and current taskcount {}", startCount);
final long startTime = System.currentTimeMillis();
executor.execute(() -> {
try {
task.run();
} finally {
int endCount = runCounter.decrementAndGet();
LOG.info("Finish task and current taskcount {} use time {}", endCount, System.currentTimeMillis()-startTime);
}
});
}
public void shutdown() {
executor.shutdown();
}
}