提交 d91d9fea 编写于 作者: W william.liangf

DUBBO-91 dubbo-monitor-simple增加服务提供者和消费者列表查看

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@422 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 56578605
......@@ -194,7 +194,7 @@ public abstract class AbstractReferenceConfig extends AbstractMethodConfig {
}
}
return UrlUtils.parseURL(monitor.getAddress(), map);
} else if (ConfigUtils.isNotEmpty(monitor.getGroup()) && registryURL != null) {
} else if (Constants.REGISTRY_PROTOCOL.equals(monitor.getProtocol()) && registryURL != null) {
return registryURL.setProtocol("dubbo").addParameter(Constants.PROTOCOL_KEY, "registry").addParameterAndEncoded(RpcConstants.REFER_KEY, StringUtils.toQueryString(map));
}
return null;
......
......@@ -31,13 +31,17 @@
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-config</artifactId>
<artifactId>dubbo-common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -15,6 +15,7 @@
*/
package com.alibaba.dubbo.container.page.pages;
import java.lang.management.ManagementFactory;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -23,6 +24,8 @@ import java.util.Locale;
import com.alibaba.dubbo.common.Extension;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.Version;
import com.alibaba.dubbo.common.utils.NetUtils;
import com.alibaba.dubbo.container.page.Menu;
import com.alibaba.dubbo.container.page.Page;
import com.alibaba.dubbo.container.page.PageHandler;
......@@ -38,28 +41,103 @@ public class SystemPageHandler implements PageHandler {
public Page handle(URL url) {
List<List<String>> rows = new ArrayList<List<String>>();
List<String> row = new ArrayList<String>();
List<String> row;
row = new ArrayList<String>();
row.add("Version");
row.add(Version.getVersion(SystemPageHandler.class, "2.0.0"));
rows.add(row);
row = new ArrayList<String>();
row.add("Host");
String address = NetUtils.getLocalHost();
row.add(NetUtils.getHostName(address) + "/" + address);
rows.add(row);
row = new ArrayList<String>();
row.add("OS");
row.add(System.getProperty("os.name") + " " + System.getProperty("os.version"));
rows.add(row);
row = new ArrayList<String>();
row.add("JVM");
row.add(System.getProperty("java.runtime.name") + " " + System.getProperty("java.runtime.version") + ",<br/>" + System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version") + " " + System.getProperty("java.vm.info", ""));
rows.add(row);
row = new ArrayList<String>();
row.add("CPU");
row.add(System.getProperty("os.arch", "") + ", " + String.valueOf(Runtime.getRuntime().availableProcessors()) + " cores");
rows.add(row);
row = new ArrayList<String>();
row.add("Time");
row.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date()));
rows.add(row);
row = new ArrayList<String>();
row.add("Locale");
row.add(Locale.getDefault().toString() + "/" + System.getProperty("file.encoding"));
rows.add(row);
row = new ArrayList<String>();
row.add("Uptime");
row.add(formatUptime(ManagementFactory.getRuntimeMXBean().getUptime()));
rows.add(row);
row = new ArrayList<String>();
row.add("Time");
row.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z").format(new Date()));
rows.add(row);
return new Page("<a href=\"/\">Home</a> &gt; System", "System", new String[] {
"Name", "Value" }, rows);
"Property", "Value" }, rows);
}
private static final long SECOND = 1000;
private static final long MINUTE = 60 * SECOND;
private static final long HOUR = 60 * MINUTE;
private static final long DAY = 24 * HOUR;
private String formatUptime(long uptime) {
StringBuilder buf = new StringBuilder();
if (uptime > DAY) {
long days = (uptime - uptime % DAY) / DAY;
buf.append(days);
buf.append(" Days");
uptime = uptime % DAY;
}
if (uptime > HOUR) {
long hours = (uptime - uptime % HOUR) / HOUR;
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(hours);
buf.append(" Hours");
uptime = uptime % HOUR;
}
if (uptime > MINUTE) {
long minutes = (uptime - uptime % MINUTE) / MINUTE;
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(minutes);
buf.append(" Minutes");
uptime = uptime % MINUTE;
}
if (uptime > SECOND) {
long seconds = (uptime - uptime % SECOND) / SECOND;
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(seconds);
buf.append(" Seconds");
uptime = uptime % SECOND;
}
if (uptime > 0) {
if (buf.length() > 0) {
buf.append(", ");
}
buf.append(uptime);
buf.append(" Milliseconds");
}
return buf.toString();
}
}
\ No newline at end of file
......@@ -34,9 +34,9 @@
<artifactId>dubbo</artifactId>
<version>${project.parent.version}</version>
</dependency>
<!--<dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
</dependency>-->
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -50,7 +50,7 @@ fi
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
echo -e "Starting dubbo registry admin server on $SERVER_PORT \c"
nohup java $JAVA_OPTS $JAVA_MEM_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main properties log4j spring jetty > $STDOUT_FILE 2>&1 &
nohup java $JAVA_OPTS $JAVA_MEM_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main properties log4j registry spring jetty > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
......
registry.url=dubbo://127.0.0.1:9090
jetty.port=8082
jetty.pages=index,registries,registered,connections,status,log,system
log4j.file=logs/dubbo-simple-monitor.log
log4j.level=INFO
\ No newline at end of file
#registry.url=dubbo://127.0.0.1:9090
#registry.url=multicast://224.5.6.7:1234
registry.url=zookeeper://127.0.0.1:2181
jetty.port=8080
jetty.pages=index,services,providers,consumers,status,log,system
log4j.file=logs/dubbo-registry-admin.log
log4j.level=WARN
\ No newline at end of file
......@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.registry.admin;
package com.alibaba.dubbo.monitor.simple;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -125,11 +126,13 @@ public class RegistryContainer implements Container {
if (urls == null || urls.size() == 0) {
return;
}
Set<String> notifiedServices = new HashSet<String>();
Map<String, List<URL>> proivderMap = new HashMap<String, List<URL>>();
Map<String, List<URL>> consumerMap = new HashMap<String, List<URL>>();
Map<String, List<URL>> routeMap = new HashMap<String, List<URL>>();
for (URL url : urls) {
String service = url.getServiceName();
notifiedServices.add(service);
services.add(service);
if (Constants.ROUTE_PROTOCOL.equals(url.getProtocol())) {
List<URL> list = routeMap.get(service);
......@@ -145,7 +148,7 @@ public class RegistryContainer implements Container {
consumerMap.put(service, list);
}
list.add(url);
} else {
} else if (! Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
List<URL> list = proivderMap.get(service);
if (list == null) {
list = new ArrayList<URL>();
......@@ -163,6 +166,17 @@ public class RegistryContainer implements Container {
if (routeMap != null && routeMap.size() > 0) {
routes.putAll(routeMap);
}
for (String service : notifiedServices) {
if (! proivderMap.containsKey(service)) {
providers.remove(service);
}
if (! consumerMap.containsKey(service)) {
consumers.remove(service);
}
if (! routeMap.containsKey(service)) {
routes.remove(service);
}
}
}
});
}
......
......@@ -15,6 +15,11 @@
*/
package com.alibaba.dubbo.monitor.simple;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;
......@@ -26,11 +31,53 @@ import com.alibaba.dubbo.monitor.MonitorService;
* @author william.liangf
*/
public class SimpleMonitorService implements MonitorService {
private static final Logger logger = LoggerFactory.getLogger(SimpleMonitorService.class);
public void count(URL statistics) {
logger.info(statistics.toString());
private static final String[] keys = {SUCCESS, FAILURE, ELAPSED, INPUT, OUTPUT, CONCURRENT, MAX_ELAPSED, MAX_INPUT, MAX_OUTPUT, MAX_CONCURRENT};
private static final Logger logger = LoggerFactory.getLogger(SimpleMonitorService.class);
private File directory;
public void setDirectory(String directory) {
this.directory = new File(directory);
if (! this.directory.exists()) {
this.directory.mkdirs();
}
}
public void count(URL statistics) {
try {
Date now = new Date();
File day = new File(directory, new SimpleDateFormat("yyyyMMdd").format(now)
+ "/" + statistics.getServiceName()
+ "/" + statistics.getParameter(METHOD));
if (! day.exists()) {
day.mkdirs();
}
SimpleDateFormat format = new SimpleDateFormat("HHmm");
for (String key : keys) {
try {
String filename;
if (statistics.hasParameter(SERVER)) {
filename = statistics.getHost() + "-" + statistics.getParameter(SERVER) + "." + key + ".log";
} else {
filename = statistics.getParameter(CLIENT) + "+" + statistics.getHost() + "." + key + ".log";
}
File file = new File(day, filename);
FileWriter writer = new FileWriter(file, true);
try {
writer.write(format.format(now) + " " + statistics.getParameter(key, 0));
writer.flush();
} finally {
writer.close();
}
} catch (Throwable t) {
logger.error(t.getMessage(), t);
}
}
} catch (Throwable t) {
logger.error(t.getMessage(), t);
}
}
}
\ No newline at end of file
......@@ -13,17 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.registry.admin;
package com.alibaba.dubbo.monitor.simple.pages;
/**
* Main
* ChartPageHandler
*
* @author william.liangf
*/
public class RegistryAdminMain {
public static void main(String[] args) {
com.alibaba.dubbo.container.Main.main(new String[] {"properties", "log4j", "registry", "jetty"});
}
public class ChartPageHandler {
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.registry.admin.pages;
package com.alibaba.dubbo.monitor.simple.pages;
import java.util.ArrayList;
import java.util.Collection;
......@@ -23,7 +23,7 @@ import com.alibaba.dubbo.common.Extension;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.container.page.Page;
import com.alibaba.dubbo.container.page.PageHandler;
import com.alibaba.dubbo.registry.admin.RegistryContainer;
import com.alibaba.dubbo.monitor.simple.RegistryContainer;
/**
* ConsumersPageHandler
......@@ -48,7 +48,7 @@ public class ConsumersPageHandler implements PageHandler {
}
nav = "<a href=\"services.html\">Services</a> &gt; " + service
+ " &gt; <a href=\"providers.html?service=" + service
+ "\">Providers</a> | Consumers | <a href=\"routes.html?service=" + service + "\">Routes</a>";
+ "\">Providers</a> | Consumers";
} else {
Collection<List<URL>> values = RegistryContainer.getInstance().getConsumers().values();
if (values != null && values.size() > 0) {
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.registry.admin.pages;
package com.alibaba.dubbo.monitor.simple.pages;
import java.util.ArrayList;
import java.util.Collection;
......@@ -23,7 +23,7 @@ import com.alibaba.dubbo.common.Extension;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.container.page.Page;
import com.alibaba.dubbo.container.page.PageHandler;
import com.alibaba.dubbo.registry.admin.RegistryContainer;
import com.alibaba.dubbo.monitor.simple.RegistryContainer;
/**
* ProvidersPageHandler
......@@ -48,7 +48,7 @@ public class ProvidersPageHandler implements PageHandler {
}
nav = "<a href=\"services.html\">Services</a> &gt; " + service
+ " &gt; Providers | <a href=\"consumers.html?service=" + service
+ "\">Consumers</a> | <a href=\"routes.html?service=" + service + "\">Routes</a>";
+ "\">Consumers</a>";
} else {
Collection<List<URL>> values = RegistryContainer.getInstance().getProviders().values();
if (values != null && values.size() > 0) {
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.registry.admin.pages;
package com.alibaba.dubbo.monitor.simple.pages;
import java.util.ArrayList;
import java.util.List;
......@@ -24,7 +24,7 @@ import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.container.page.Menu;
import com.alibaba.dubbo.container.page.Page;
import com.alibaba.dubbo.container.page.PageHandler;
import com.alibaba.dubbo.registry.admin.RegistryContainer;
import com.alibaba.dubbo.monitor.simple.RegistryContainer;
/**
* ServicesPageHandler
......@@ -40,7 +40,6 @@ public class ServicesPageHandler implements PageHandler {
List<List<String>> rows = new ArrayList<List<String>>();
int providerCount = 0;
int consumerCount = 0;
int routeCount = 0;
if (services != null && services.size() > 0) {
for (String service : services) {
List<String> row = new ArrayList<String>();
......@@ -53,15 +52,11 @@ public class ServicesPageHandler implements PageHandler {
int consumerSize = consumers == null ? 0 : consumers.size();
consumerCount += consumerSize;
row.add("<a href=\"consumers.html?service=" + service + "\">Consumers(" + consumerSize + ")</a>");
List<URL> routes = RegistryContainer.getInstance().getRoutes(service);
int routeSize = routes == null ? 0 : routes.size();
routeCount += routeSize;
row.add("<a href=\"routes.html?service=" + service + "\">Routes(" + routeSize + ")</a>");
rows.add(row);
}
}
return new Page("<a href=\"/\">Home</a> &gt; Services", "Services (" + rows.size() + ")",
new String[] { "Service Name:", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")", "Routes(" + routeCount + ")" }, rows);
new String[] { "Service Name:", "Providers(" + providerCount + ")", "Consumers(" + consumerCount + ")" }, rows);
}
}
com.alibaba.dubbo.monitor.simple.RegistryContainer
\ No newline at end of file
com.alibaba.dubbo.registry.admin.pages.ServicesPageHandler
com.alibaba.dubbo.registry.admin.pages.ProvidersPageHandler
com.alibaba.dubbo.registry.admin.pages.ConsumersPageHandler
com.alibaba.dubbo.registry.admin.pages.RoutesPageHandler
\ No newline at end of file
com.alibaba.dubbo.registry.admin.pages.ConsumersPageHandler
\ No newline at end of file
com.alibaba.dubbo.monitor.dubbo.DubboMonitorFactroy
\ No newline at end of file
......@@ -4,13 +4,18 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="location" value="classpath:system.properties" />
</bean>
<dubbo:application name="simple-monitor" />
<dubbo:registry address="127.0.0.1:9090" />
<dubbo:registry address="${registry.url}" />
<dubbo:protocol port="7070" />
<dubbo:protocol port="${monitor.port}" />
<dubbo:service interface="com.alibaba.dubbo.monitor.MonitorService" ref="monitorService" group="simple" />
<dubbo:service interface="com.alibaba.dubbo.monitor.MonitorService" ref="monitorService" />
<bean id="monitorService" class="com.alibaba.dubbo.monitor.simple.SimpleMonitorService" />
......
registry.url=dubbo://127.0.0.1:9090
jetty.port=8082
jetty.pages=index,registries,registered,connections,status,log,system
log4j.file=logs/dubbo-simple-monitor.log
#registry.url=dubbo://127.0.0.1:9090
#registry.url=multicast://224.5.6.7:1234
registry.url=zookeeper://10.20.153.10:2181
monitor.port=7070
jetty.port=8080
jetty.pages=index,services,providers,consumers,status,log,system
log4j.file=logs/dubbo-registry-admin.log
log4j.level=INFO
\ No newline at end of file
<!--
- Copyright 1999-2011 Alibaba Group.
-
- Licensed 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-parent</artifactId>
<version>2.0.9-SNAPSHOT</version>
</parent>
<artifactId>dubbo-registry-admin</artifactId>
<packaging>jar</packaging>
<name>Dubbo Registry Admin Module</name>
<description>The registry admin module of dubbo project</description>
<properties>
<skip_maven_deploy>false</skip_maven_deploy>
</properties>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<assembly>
<id>assembly</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/assembly/bin</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>src/main/assembly/conf</directory>
<outputDirectory>conf</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
\ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
KILL_PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" |awk '{print $2}'`
if [ -z "$KILL_PIDS" ]; then
echo "Dubbo registry admin server does not started!"
exit 1;
fi
echo -e "Stopping dubbo registry admin server \c"
for PID in $KILL_PIDS ; do
echo -e "$PID \c"
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $KILL_PIDS ; do
PID_PS=`ps --no-heading -p $PID`
if [ -n "$PID_PS" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $KILL_PIDS"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/conf
LIB_DIR=$DEPLOY_DIR/lib
LOGS_DIR=$DEPLOY_DIR/logs
STDOUT_FILE=$LOGS_DIR/stdout.log
SERVER_PORT=$1
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
if [ -z "$SERVER_PORT" ]; then
SERVER_PORT=8080
fi
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "********************************************************************"
echo "** Error: Dubbo registry admin server port $SERVER_PORT already used!"
echo "********************************************************************"
exit 1
fi
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
let memTotal=`cat /proc/meminfo |grep MemTotal|awk '{printf "%d", $2/1024 }'`
if [ $memTotal -gt 2500 ];then
JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
fi
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
EXIST_PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" |awk '{print $2}'`
if [ ! -z "$EXIST_PIDS" ]; then
echo "Dubbo registry admin server already started!"
echo "PID: $EXIST_PIDS"
exit;
fi
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
echo -e "Starting dubbo registry admin server on $SERVER_PORT \c"
nohup java $JAVA_OPTS $JAVA_MEM_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main properties log4j registry jetty > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=`curl -s "http://127.0.0.1:$SERVER_PORT/status" |grep -c "OK"`
if [ $COUNT -lt 1 ]; then
break
fi
done
echo "OK!"
START_PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" |awk '{print $2}'`
echo "PID: $START_PIDS"
echo "========================================================="
tail -f $STDOUT_FILE
registry.url=zookeeper://127.0.0.1:2181
jetty.port=8080
jetty.pages=index,services,providers,consumers,routes,registries,status,log,system
log4j.file=logs/dubbo-registry-admin.log
log4j.level=WARN
\ No newline at end of file
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed 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 com.alibaba.dubbo.registry.admin.pages;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.alibaba.dubbo.common.Extension;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.container.page.Page;
import com.alibaba.dubbo.container.page.PageHandler;
import com.alibaba.dubbo.registry.admin.RegistryContainer;
import com.alibaba.dubbo.rpc.RpcConstants;
/**
* RoutesPageHandler
*
* @author william.liangf
*/
@Extension("routes")
public class RoutesPageHandler implements PageHandler {
public Page handle(URL url) {
String service = url.getParameter("service");
List<List<String>> rows = new ArrayList<List<String>>();
String nav;
if (service != null && service.length() > 0) {
List<URL> routes = RegistryContainer.getInstance().getRoutes(service);
if (routes != null && routes.size() > 0) {
for (URL route : routes) {
List<String> row = new ArrayList<String>();
row.add(route.getParameter(RpcConstants.TYPE_KEY));
row.add(route.getParameterAndDecoded(RpcConstants.RULE_KEY).replace("<", "lt;").replace(">", "gt;"));
rows.add(row);
}
}
nav = "<a href=\"services.html\">Services</a> &gt; " + service
+ " &gt; <a href=\"providers.html?service=" + service + "\">Providers</a> | <a href=\"consumers.html?service=" + service
+ "\">Consumers</a> | Routes";
} else {
Collection<List<URL>> values = RegistryContainer.getInstance().getRoutes().values();
if (values != null && values.size() > 0) {
for (List<URL> routes : values) {
if (routes != null && routes.size() > 0) {
for (URL route : routes) {
List<String> row = new ArrayList<String>();
row.add(route.getParameter(RpcConstants.TYPE_KEY));
row.add(route.getParameterAndDecoded(RpcConstants.RULE_KEY).replace("<", "lt;").replace(">", "gt;"));
rows.add(row);
}
}
}
}
nav = "Routes";
}
return new Page("<a href=\"/\">Home</a> &gt; " + nav, "Routes (" + rows.size() + ")",
new String[] { "Route Type:", "Route Rule:" }, rows);
}
}
com.alibaba.dubbo.registry.admin.RegistryContainer
\ No newline at end of file
registry.url=dubbo://127.0.0.1:9090
jetty.port=8080
jetty.pages=index,services,providers,consumers,routes,registries,status,log,system
log4j.file=logs/dubbo-registry-admin.log
log4j.level=INFO
\ No newline at end of file
......@@ -50,7 +50,7 @@ fi
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
echo -e "Starting dubbo registry admin server on $SERVER_PORT \c"
nohup java $JAVA_OPTS $JAVA_MEM_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main properties log4j spring jetty > $STDOUT_FILE 2>&1 &
nohup java $JAVA_OPTS $JAVA_MEM_OPTS -classpath $CONF_DIR:$LIB_JARS com.alibaba.dubbo.container.Main properties log4j spring > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
......
jetty.port=8081
jetty.pages=index,registries,registered,connections,status,log,system
log4j.file=logs/dubbo-simple-monitor.log
log4j.level=INFO
\ No newline at end of file
log4j.file=logs/dubbo-simple-registry.log
log4j.level=WARN
\ No newline at end of file
......@@ -33,6 +33,11 @@
<groupId>com.alibaba</groupId>
<artifactId>dubbo-cluster</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-container</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.container.page.pages;
package com.alibaba.dubbo.registry.pages;
import java.util.ArrayList;
import java.util.Collection;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.dubbo.container.page.pages;
package com.alibaba.dubbo.registry.pages;
import java.util.ArrayList;
import java.util.Collection;
......
......@@ -31,7 +31,7 @@
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo-container</artifactId>
<artifactId>dubbo-config</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
......
......@@ -48,7 +48,6 @@
<module>dubbo-config</module>
<module>dubbo-container</module>
<module>dubbo</module>
<module>dubbo-registry-admin</module>
<module>dubbo-registry-simple</module>
<module>dubbo-monitor-simple</module>
</modules>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册