diff --git a/internal-service/service-api/pom.xml b/internal-service/service-api/pom.xml index 0f3df8723d05524346a21d2d4d7e2c2c317b6733..3e3a112a95e7836a0c779994c46604852ed1c38f 100644 --- a/internal-service/service-api/pom.xml +++ b/internal-service/service-api/pom.xml @@ -11,5 +11,20 @@ <artifactId>service-api</artifactId> + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.dubbo</groupId> + <artifactId>dubbo</artifactId> + </dependency> + </dependencies> </project> \ No newline at end of file diff --git a/internal-service/service-consumer/pom.xml b/internal-service/service-consumer/pom.xml index efb9a1e09321dde99369fcd16054935c7b18c0ff..3ad3b7b9da7fac1b6e4259968f47f065b6480b0e 100644 --- a/internal-service/service-consumer/pom.xml +++ b/internal-service/service-consumer/pom.xml @@ -16,14 +16,6 @@ <groupId>com.aliware.tianchi</groupId> <artifactId>service-api</artifactId> </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo</artifactId> - </dependency> </dependencies> <build> diff --git a/internal-service/service-consumer/src/main/java/com/aliware/tianchi/MyConsumer.java b/internal-service/service-consumer/src/main/java/com/aliware/tianchi/MyConsumer.java index 3108833583be9bab6ad23ef110c57ab190a0579e..f69b0e21600b316d484a8e0765bb835efd56e0a0 100644 --- a/internal-service/service-consumer/src/main/java/com/aliware/tianchi/MyConsumer.java +++ b/internal-service/service-consumer/src/main/java/com/aliware/tianchi/MyConsumer.java @@ -1,20 +1,47 @@ package com.aliware.tianchi; import java.io.IOException; -import org.springframework.context.support.ClassPathXmlApplicationContext; +import java.util.Collections; +import org.apache.dubbo.common.Constants; +import org.apache.dubbo.common.URL; +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ReferenceConfig; +import org.apache.dubbo.config.RegistryConfig; -/** - * @author guohaoice@gmail.com - */ + +/** @author guohaoice@gmail.com */ public class MyConsumer { public static void main(String[] args) throws IOException, InterruptedException { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"classpath:dubbo-consumer.xml"}); - context.start(); - HashInterface bean = context.getBean(HashInterface.class); - while(true){ + // 当å‰åº”用é…ç½® + ApplicationConfig application = new ApplicationConfig(); + application.setName("service-gateway"); + + // 连接注册ä¸å¿ƒé…ç½® + RegistryConfig registry = new RegistryConfig(); +// String address="com.aliware.tianchi.HashInterface-" +// +"localhost:20880_" +// +"localhost:20880"; +// registry.setAddress("list://localhost:9999"); + registry.setAddress("N/A"); +// registry.setParameters(Collections.singletonMap(LIST_URL_KEY,address)); + + + // 注æ„:ReferenceConfig为é‡å¯¹è±¡ï¼Œå†…部å°è£…了与注册ä¸å¿ƒçš„连接,以åŠä¸ŽæœåŠ¡æ供方的连接 + + // 引用远程æœåŠ¡ + ReferenceConfig<HashInterface> reference = + new ReferenceConfig<HashInterface>(); // æ¤å®žä¾‹å¾ˆé‡ï¼Œå°è£…了与注册ä¸å¿ƒçš„连接以åŠä¸Žæ供者的连接,请自行缓å˜ï¼Œå¦åˆ™å¯èƒ½é€ æˆå†…å˜å’Œè¿žæŽ¥æ³„æ¼ + reference.setApplication(application); + reference.setRegistry(registry); // 多个注册ä¸å¿ƒå¯ä»¥ç”¨setRegistries() + reference.setInterface(HashInterface.class); +// reference.setUrl(new URL(Constants.DUBBO_PROTOCOL,"localhost",20880,reference.getInterface())); + reference.setUrl("localhost:20880"); + + // 和本地beanä¸€æ ·ä½¿ç”¨xxxService + HashInterface service = reference.get(); // 注æ„:æ¤ä»£ç†å¯¹è±¡å†…部å°è£…了所有通讯细节,对象较é‡ï¼Œè¯·ç¼“å˜å¤ç”¨ + while (true) { Thread.sleep(1000); - System.out.println(bean.hash("hahaha")); + System.out.println(service.hash("hahaha")); } -// System.in.read(); // press any key to exit } } diff --git a/internal-service/service-consumer/src/main/resources/dubbo-consumer.xml b/internal-service/service-consumer/src/main/resources/dubbo-consumer.xml index f25a6e957747a7497fe950c196e1d075ec780f46..72f887b84bd131480e6dc43c6f2a9ca3649ffe5d 100644 --- a/internal-service/service-consumer/src/main/resources/dubbo-consumer.xml +++ b/internal-service/service-consumer/src/main/resources/dubbo-consumer.xml @@ -9,10 +9,10 @@ <dubbo:application name="demo-consumer"/> <!-- use multicast registry center to discover service --> - <!--<dubbo:registry address="zookeeper://127.0.0.1:2181"/>--> + <dubbo:registry address="list://127.0.0.1:2181"/> <!-- generate proxy for the remote service, then demoService can be used in the same way as the local regular interface --> - <dubbo:reference id="directService" check="false" interface="com.aliware.tianchi.HashInterface" url="localhost:20880"/> + <dubbo:reference id="directService" check="false" interface="com.aliware.tianchi.HashInterface" /> </beans> \ No newline at end of file diff --git a/internal-service/service-consumer/src/main/resources/logback.xml b/internal-service/service-consumer/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..946213798813423e6339cc6a3e5616c78ac9e975 --- /dev/null +++ b/internal-service/service-consumer/src/main/resources/logback.xml @@ -0,0 +1,22 @@ +<configuration> + <appender name="FILE" class="ch.qos.logback.core.FileAppender"> + <file>service-provider.log</file> + <encoder> + <pattern>%date %level [%thread] %logger{10} [%file : %line] %msg%n</pattern> + </encoder> + </appender> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%msg%n</pattern> + </encoder> + </appender> + + <logger name="chapters.configuration.Foo" additivity="false"> + <appender-ref ref="FILE" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> +</configuration> \ No newline at end of file diff --git a/internal-service/service-provider/pom.xml b/internal-service/service-provider/pom.xml index 8e98468370c75939c273630ea521ae781de3cd5e..91ebdbfb8d814d6db4faa884f25b399f3e4aeab8 100644 --- a/internal-service/service-provider/pom.xml +++ b/internal-service/service-provider/pom.xml @@ -11,6 +11,7 @@ <artifactId>service-provider</artifactId> + <dependencies> <dependency> <groupId>com.aliware.tianchi</groupId> @@ -20,13 +21,8 @@ <groupId>org.apache.dubbo</groupId> <artifactId>dubbo</artifactId> </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-dependencies-zookeeper</artifactId> - </dependency> </dependencies> - <build> <plugins> <plugin> diff --git a/internal-service/service-provider/src/main/java/com/aliware/tianchi/DemoProviderMain.java b/internal-service/service-provider/src/main/java/com/aliware/tianchi/DemoProviderMain.java index 0f3deec461a60ba38ac939b8cf3c66d1d2124cef..a7fffecc8fbb7262921cd43c091f4da1f05f1a00 100644 --- a/internal-service/service-provider/src/main/java/com/aliware/tianchi/DemoProviderMain.java +++ b/internal-service/service-provider/src/main/java/com/aliware/tianchi/DemoProviderMain.java @@ -1,21 +1,66 @@ package com.aliware.tianchi; import java.io.IOException; -import org.springframework.context.support.ClassPathXmlApplicationContext; +import java.util.List; +import com.aliware.tianchi.policy.SmallConfig; +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.ServiceConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @author guohaoice@gmail.com */ public class DemoProviderMain { + private static final Logger LOGGER = LoggerFactory.getLogger(DemoProviderMain.class); + public static void main(String[] args) throws IOException { - // if(args.length!=3){ - // throw new IllegalArgumentException("Bad argument number"); - // } - - // String salt=args[0]; - // System.out.println(salt); - new EmbeddedZooKeeper(2181, false).start(); - ClassPathXmlApplicationContext context = - new ClassPathXmlApplicationContext(new String[] {"classpath:dubbo-provider.xml"}); - context.start(); + String env; + String salt; + if (args.length != 3) { + LOGGER.info("No specific args found, use [DEFAULT] to run demo provider"); + env = "small"; + salt = "salt_val"; + } else { + env = args[0]; + salt = args[1]; + } + List<ThrashConfig> configs; + switch (env) { + case "small": + configs = new SmallConfig().allConfig; + break; + default: + configs = new SmallConfig().allConfig; + } + + // 当å‰åº”用é…ç½® + ApplicationConfig application = new ApplicationConfig(); + application.setName("service-provider"); + + // 连接注册ä¸å¿ƒé…ç½® + RegistryConfig registry = new RegistryConfig(); + registry.setAddress("N/A"); + + // æœåŠ¡æ供者åè®®é…ç½® + ProtocolConfig protocol = new ProtocolConfig(); + protocol.setName("dubbo"); + protocol.setPort(20880); + protocol.setThreads(200); + + // 注æ„:ServiceConfig为é‡å¯¹è±¡ï¼Œå†…部å°è£…了与注册ä¸å¿ƒçš„连接,以åŠå¼€å¯æœåŠ¡ç«¯å£ + + // æœåŠ¡æ供者暴露æœåŠ¡é…ç½® + ServiceConfig<HashInterface> service = + new ServiceConfig<>(); // æ¤å®žä¾‹å¾ˆé‡ï¼Œå°è£…了与注册ä¸å¿ƒçš„连接,请自行缓å˜ï¼Œå¦åˆ™å¯èƒ½é€ æˆå†…å˜å’Œè¿žæŽ¥æ³„æ¼ + service.setApplication(application); + service.setRegistry(registry); // 多个注册ä¸å¿ƒå¯ä»¥ç”¨setRegistries() + service.setProtocol(protocol); // 多个åè®®å¯ä»¥ç”¨setProtocols() + service.setInterface(HashInterface.class); + service.setRef(new HashServiceImpl(salt, configs)); + + // 暴露åŠæ³¨å†ŒæœåŠ¡ + service.export(); System.in.read(); // press any key to exit } } diff --git a/internal-service/service-provider/src/main/java/com/aliware/tianchi/EmbeddedZooKeeper.java b/internal-service/service-provider/src/main/java/com/aliware/tianchi/EmbeddedZooKeeper.java deleted file mode 100644 index b0b68e3fe4105f12d4d27c8ffc9204931714f3d6..0000000000000000000000000000000000000000 --- a/internal-service/service-provider/src/main/java/com/aliware/tianchi/EmbeddedZooKeeper.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * 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.aliware.tianchi; - -import java.io.File; -import java.lang.reflect.Method; -import java.util.Properties; -import java.util.UUID; -import org.apache.zookeeper.server.ServerConfig; -import org.apache.zookeeper.server.ZooKeeperServerMain; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.SmartLifecycle; -import org.springframework.util.ErrorHandler; -import org.springframework.util.SocketUtils; - -/** - * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java - * - * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper. - * - * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for -// * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication} - * - * @author Patrick Peralta - * @author Mark Fisher - * @author David Turanski - */ -public class EmbeddedZooKeeper implements SmartLifecycle { - - /** - * Logger. - */ -// private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class); - - /** - * ZooKeeper client port. This will be determined dynamically upon startup. - */ - private final int clientPort; - - /** - * Whether to auto-start. Default is true. - */ - private boolean autoStartup = true; - - /** - * Lifecycle phase. Default is 0. - */ - private int phase = 0; - - /** - * Thread for running the ZooKeeper server. - */ - private volatile Thread zkServerThread; - - /** - * ZooKeeper server. - */ - private volatile ZooKeeperServerMain zkServer; - - /** - * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. - */ - private ErrorHandler errorHandler; - - private boolean daemon = true; - - /** - * Construct an EmbeddedZooKeeper with a random port. - */ - public EmbeddedZooKeeper() { - clientPort = SocketUtils.findAvailableTcpPort(); - } - - /** - * Construct an EmbeddedZooKeeper with the provided port. - * - * @param clientPort port for ZooKeeper server to bind to - */ - public EmbeddedZooKeeper(int clientPort, boolean daemon) { - this.clientPort = clientPort; - this.daemon = daemon; - } - - /** - * Returns the port that clients should use to connect to this embedded server. - * - * @return dynamically determined client port - */ - public int getClientPort() { - return this.clientPort; - } - - /** - * Specify whether to start automatically. Default is true. - * - * @param autoStartup whether to start automatically - */ - public void setAutoStartup(boolean autoStartup) { - this.autoStartup = autoStartup; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAutoStartup() { - return this.autoStartup; - } - - /** - * Specify the lifecycle phase for the embedded server. - * - * @param phase the lifecycle phase - */ - public void setPhase(int phase) { - this.phase = phase; - } - - /** - * {@inheritDoc} - */ - @Override - public int getPhase() { - return this.phase; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isRunning() { - return (zkServerThread != null); - } - - /** - * Start the ZooKeeper server in a background thread. - * <p> - * Register an error handler via {@link #setErrorHandler} in order to handle - * any exceptions thrown during startup or execution. - */ - @Override - public synchronized void start() { - if (zkServerThread == null) { - zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter"); - zkServerThread.setDaemon(daemon); - zkServerThread.start(); - } - } - - /** - * Shutdown the ZooKeeper server. - */ - @Override - public synchronized void stop() { - if (zkServerThread != null) { - // The shutdown method is protected...thus this hack to invoke it. - // This will log an exception on shutdown; see - // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details. - try { - Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown"); - shutdown.setAccessible(true); - shutdown.invoke(zkServer); - } - - catch (Exception e) { - throw new RuntimeException(e); - } - - // It is expected that the thread will exit after - // the server is shutdown; this will block until - // the shutdown is complete. - try { - zkServerThread.join(5000); - zkServerThread = null; - } - catch (InterruptedException e) { - Thread.currentThread().interrupt(); -// logger.warn("Interrupted while waiting for embedded ZooKeeper to exit"); - // abandoning zk thread - zkServerThread = null; - } - } - } - - /** - * Stop the server if running and invoke the callback when complete. - */ - @Override - public void stop(Runnable callback) { - stop(); - callback.run(); - } - - /** - * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none - * is provided, only error-level logging will occur. - * - * @param errorHandler the {@link ErrorHandler} to be invoked - */ - public void setErrorHandler(ErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - /** - * Runnable implementation that starts the ZooKeeper server. - */ - private class ServerRunnable implements Runnable { - - @Override - public void run() { - try { - Properties properties = new Properties(); - File file = new File(System.getProperty("java.io.tmpdir") - + File.separator + UUID.randomUUID()); - file.deleteOnExit(); - properties.setProperty("dataDir", file.getAbsolutePath()); - properties.setProperty("clientPort", String.valueOf(clientPort)); - - QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig(); - quorumPeerConfig.parseProperties(properties); - - zkServer = new ZooKeeperServerMain(); - ServerConfig configuration = new ServerConfig(); - configuration.readFrom(quorumPeerConfig); - - zkServer.runFromConfig(configuration); - } - catch (Exception e) { - if (errorHandler != null) { - errorHandler.handleError(e); - } - else { -// logger.error("Exception running embedded ZooKeeper", e); - } - } - } - } - -} \ No newline at end of file diff --git a/internal-service/service-provider/src/main/java/com/aliware/tianchi/HashServiceImpl.java b/internal-service/service-provider/src/main/java/com/aliware/tianchi/HashServiceImpl.java index 8fc4b895c245c01739fe5111b514da375777bf28..614cee9b04c3bec95d92be0fcaa58c331f49f522 100644 --- a/internal-service/service-provider/src/main/java/com/aliware/tianchi/HashServiceImpl.java +++ b/internal-service/service-provider/src/main/java/com/aliware/tianchi/HashServiceImpl.java @@ -2,13 +2,15 @@ package com.aliware.tianchi; import java.util.Collections; import java.util.List; +import java.util.Random; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.Semaphore; -import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import org.apache.dubbo.common.utils.NamedThreadFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Facade @@ -16,14 +18,18 @@ import org.apache.dubbo.common.utils.NamedThreadFactory; * @author guohaoice@gmail.com */ public class HashServiceImpl implements HashInterface { + private static final Logger LOGGER = LoggerFactory.getLogger(HashServiceImpl.class); + private final String salt; private final AtomicBoolean init = new AtomicBoolean(false); private final List<ThrashConfig> configs; private volatile ThrashConfig config; + private Random rng = new Random(2019); private ScheduledExecutorService scheduler = - new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Benchmark-refresh-permit")); + new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("HashService-Refresher")); + public HashServiceImpl(String salt) { - this(salt,Collections.emptyList()); + this(salt, Collections.emptyList()); } public HashServiceImpl(String salt, List<ThrashConfig> configs) { @@ -34,6 +40,7 @@ public class HashServiceImpl implements HashInterface { @Override public int hash(String input) { + long st = System.currentTimeMillis(); if (!init.get()) { if (init.compareAndSet(false, true)) { int startTime = 0; @@ -53,6 +60,8 @@ public class HashServiceImpl implements HashInterface { } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { + long cost = System.currentTimeMillis() - st; + LOGGER.info("HashService cost:{} ms to handle request", cost); permit.release(); } throw new IllegalStateException("Unexpected exception"); @@ -63,7 +72,6 @@ public class HashServiceImpl implements HashInterface { } private long nextRTT() { - ThreadLocalRandom rng = ThreadLocalRandom.current(); double u = rng.nextDouble(); int x = 0; double cdf = 0; diff --git a/internal-service/service-provider/src/main/java/com/aliware/tianchi/ThrashConfig.java b/internal-service/service-provider/src/main/java/com/aliware/tianchi/ThrashConfig.java index 9aa3ed71e1c7b2aabf6113f5146dfc174c0449f8..cf77000573203f195cbe18d58b5c6639446ba87b 100644 --- a/internal-service/service-provider/src/main/java/com/aliware/tianchi/ThrashConfig.java +++ b/internal-service/service-provider/src/main/java/com/aliware/tianchi/ThrashConfig.java @@ -8,13 +8,11 @@ import java.util.concurrent.Semaphore; public class ThrashConfig { public static final ThrashConfig INIT_CONFIG=new ThrashConfig(4000,Integer.MAX_VALUE,10); final long durationInMs; - final int maxConcurrency; final int averageRTTInMs; final Semaphore permit; public ThrashConfig(long durationInMs, int maxConcurrency, int averageRTTInMs) { this.durationInMs = durationInMs; - this.maxConcurrency = maxConcurrency; this.averageRTTInMs = averageRTTInMs; this.permit=new Semaphore(maxConcurrency); } diff --git a/internal-service/service-provider/src/main/java/com/aliware/tianchi/policy/SmallConfig.java b/internal-service/service-provider/src/main/java/com/aliware/tianchi/policy/SmallConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..30db975a577ca29cdb4f4b89ed163d30db813b1a --- /dev/null +++ b/internal-service/service-provider/src/main/java/com/aliware/tianchi/policy/SmallConfig.java @@ -0,0 +1,25 @@ +package com.aliware.tianchi.policy; + +import java.util.Arrays; +import java.util.List; +import com.aliware.tianchi.ThrashConfig; + +/** + * @author guohaoice@gmail.com + */ +public class SmallConfig { + private final int baseRTT=20; + private final int onePeriodInMs=20_000; + private final int baseMaxConcurrency=10_000; + private final ThrashConfig config1=new ThrashConfig(onePeriodInMs,baseMaxConcurrency,baseRTT/2); + private final ThrashConfig config2=new ThrashConfig(onePeriodInMs,baseMaxConcurrency,baseRTT); + private final ThrashConfig config3=new ThrashConfig(onePeriodInMs,baseMaxConcurrency/2,baseRTT); + private final ThrashConfig config4=new ThrashConfig(onePeriodInMs,baseMaxConcurrency,baseRTT); + private final ThrashConfig config5=new ThrashConfig(onePeriodInMs,baseMaxConcurrency/2,baseRTT*2); + private final ThrashConfig config6=new ThrashConfig(onePeriodInMs,baseMaxConcurrency*2,baseRTT); + private final ThrashConfig config7=new ThrashConfig(onePeriodInMs,baseMaxConcurrency,baseRTT); + private final ThrashConfig config8=new ThrashConfig(onePeriodInMs,baseMaxConcurrency*2,baseRTT/2); + private final ThrashConfig config9=new ThrashConfig(onePeriodInMs,baseMaxConcurrency,baseRTT); + + public final List<ThrashConfig> allConfig= Arrays.asList(config1,config2,config3,config4,config5,config6,config7,config8,config9); +} diff --git a/internal-service/service-provider/src/main/resources/dubbo-provider.xml b/internal-service/service-provider/src/main/resources/dubbo-provider.xml deleted file mode 100644 index 2acb173345f9463a9f75c5bca1483a3d322c4bd0..0000000000000000000000000000000000000000 --- a/internal-service/service-provider/src/main/resources/dubbo-provider.xml +++ /dev/null @@ -1,21 +0,0 @@ -<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:dubbo="http://dubbo.apache.org/schema/dubbo" - xmlns="http://www.springframework.org/schema/beans" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd - http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"> - - <!-- provider's application name, used for tracing dependency relationship --> - <dubbo:application name="demo-provider"/> - <!-- use multicast registry center to export service --> - <dubbo:registry address="zookeeper://127.0.0.1:2181"/> - <!-- use dubbo protocol to export service on port 20880 --> - <dubbo:protocol name="dubbo" port="20880"/> - <!-- service implementation, as same as regular local bean --> - <bean id="demoService" class="com.aliware.tianchi.HashServiceImpl"> -<!-- <constructor-arg index="0" value=""/>--> -<!-- <constructor-arg index="1" value="10000000"/>--> - <constructor-arg index="0" value="salt-value"/> - </bean> - <!-- declare the service interface to be exported --> - <dubbo:service interface="com.aliware.tianchi.HashInterface" ref="demoService"/> -</beans> \ No newline at end of file diff --git a/internal-service/service-provider/src/main/resources/logback.xml b/internal-service/service-provider/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..946213798813423e6339cc6a3e5616c78ac9e975 --- /dev/null +++ b/internal-service/service-provider/src/main/resources/logback.xml @@ -0,0 +1,22 @@ +<configuration> + <appender name="FILE" class="ch.qos.logback.core.FileAppender"> + <file>service-provider.log</file> + <encoder> + <pattern>%date %level [%thread] %logger{10} [%file : %line] %msg%n</pattern> + </encoder> + </appender> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%msg%n</pattern> + </encoder> + </appender> + + <logger name="chapters.configuration.Foo" additivity="false"> + <appender-ref ref="FILE" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> +</configuration> \ No newline at end of file diff --git a/pom.xml b/pom.xml index f3e4412702e5d142ef4b7ca85c5fbe52487a08b6..f3753cfd88a8d48cea44d843248c9a693fe5e90d 100644 --- a/pom.xml +++ b/pom.xml @@ -61,9 +61,14 @@ <!--internal end--> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>4.3.23.RELEASE</version> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.26</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.2.3</version> </dependency> </dependencies> </dependencyManagement>