#
https://github.com/abdulwaheed18/Slf4jTutorial
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>testFile7.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover
Once any of the below condition met, it will change the file name as below and compressed it. -->
<fileNamePattern>logFile.%d{yyyy-MM-dd}.%i.log.zip
</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
<!-- or whenever the file size reaches 10MB -->
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
property文件有几份,如
mongo_dev.properties
#intranet
mongo.replicationset=10.120.141.229:27017,10.120.141.226:27017,10.120.141.228:27017
mongo.username=cms
mongo.password=cms
mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true
mongo.debug=true
mongo.trace=true
mongo_test.properties
#internet
mongo.replicationset=10.120.11.221:27017,10.120.11.122:27017,10.120.11.212:27017
mongo.username=cms
mongo.password=cms
mongo.dbname=cms
mongo.connectionsPerHost=100
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.maxWaitTime=1500
mongo.socketTimeout=1500
mongo.connectTimeout=1000
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.slaveOk=true
mongo.debug=false
mongo.trace=false
Spring的配置文件中加入
<context:property-placeholder
location="classpath*:/properties/mongodb/mongo_${spring.profiles.active}.properties />
#将下面参数放在JVM中,如果是TOMCAT则放在catalina.sh
#开发:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=dev "
#测试:
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=test "
#如果是ECLIPSE中启动TOMCAT,则只需加
-Dspring.profiles.active=dev
Packt Publishing celebrates their 2000th title with an exclusive offer - We've got IT covered!
Known for their
extensive range of pragmatic IT ebooks, Packt
Publishing are celebrating their 2000th book title `Learning Dart’– they want
their customers to celebrate too.
To mark this
milestone Packt Publishing will launch a ‘Buy One Get One Free’ offer across
all eBooks on March 18th – for a limited period only.
Packt is one of
the most prolific and fast-growing tech book publishers in the world.
Originally focused on open source software, Packt contributes back into the
community paying a royalty on relevant books directly to open source projects.
These projects have received over $400,000 as part of Packt’s Open Source
Royalty Scheme to date.
Their books focus
on practicality, recognising that readers are ultimately concerned with getting
the job done. Packt’s digitally-focused business model allows them to quickly
publish up-to-date books in very specific areas across a range of key
categories – web development, game development, big data, application
development, and more. Their commitment to providing a comprehensive range of
titles has seen Packt publish 1054% more titles in 2013 than in 2006.
Here are some of
the best titles across Packt's main categories - but Buy One, Get One Free will
apply across all 2000 titles:
·
Web
Development
·
Big
Data & Cloud
·
Game
Development
·
App
Development
通常数据库是安装在一台服务器上,如果服务器DOWN机,则数据服务停止。这样在生产环境是不合适的,必须部署两台以上的服务器且都安装有相同数据的数据库。这样就产生了一个问题,同一份数据在不同的机子上,会导致数据不同步的问题。一般的方案是:
服务端:
互责数据同步,一台服务器专门做写操作,其他服务器只做读操作,即主从模式。当主服务器DOWN机时,会在从服务器中选出一台做主服务器。在MONGODB中叫REPLICATION。
客户端:
要判断当前与数据库的链接,如果是读操作,则使用与从服务器的链接,如果是写操作,则使用与主服务器的链接。这样的判断一般是由驱动程序去做,配置的时候如果是MYSQL,就要使用REPLYCATION的驱动。
如果数据库里的某张表数据太多,会导致简单的查询会需时过长的问题。一般的方案是限制每张表中不能放太多的数据,如第一个月的数据放一张表,下一个月的数据放第二张表,这种做法称为SHARDING,分表。但这样会导致查询的复杂性,如数据在第二张表,则要具体指明表名,否则查不出数据。目前的数据库,可以事先指定分表的规则,这样查询的语句不需改变,数据库端会自动判断数据在哪张表,然后路由到那张表,去查找数据然后返回给客户端。ORACLE叫分区表,MONGODB叫AUTO SHARDING。
服务端:
需事先指定数据分表规则,这样收到查询语句时数据库就知道数据在哪张表中。
客户端:
查询数据时无需再指定分区表名了
TOMCAT集群时的SESSION如果是采用集群中的机子互相拷贝的话,会带来性能问题,一般是保存到数据库中。如果是高并发的系统,一般是保存至MONGODB中。
现有一开源的项目是做这个的:
https://github.com/simplicityitself/Mongo-Tomcat-Sessions
db:sessions, collection:sessions,相应配置在conf目录下context.xml中的如下:
<Valve className="com.dawsonsystems.session.MongoSessionTrackerValve" />
<Manager className="com.dawsonsystems.session.MongoManager" host="10.120.11.221,10.120.11.122,10.120.11.212" port="27017" database="sessions" maxInactiveInterval="60"/>
MEMCACHED版:
http://www.oschina.net/p/memcached-session-manager
摘要: 3.1需求模型简介IEEE的软件工程标准术语表将“需求”定义为:用户所需的解决某个问题或达到某个目标所要具备的条件或能力。系统或系统组件为符合合同、标准、规范或其它正式文档而必须满足的条件或必须具备的能力。上述第一项或第二项中定义的条件和能力的文档表述。RUP将“需求”定义为:需求描述了系统必须满足的情况或提供的能力,它就可以是直接来自客户需要,也可...
阅读全文
摘要: 一波在线http://www.sxpeot.tkhttp://fineflight.tkhttp://furtherserviceds.tkhttp://themostro.tkhttp://lyard.tkhttp://besureascend.tkhttp://denningsan.tkhttp://www.symantecsecured.tkhttp://wanthit.tkhttp://w...
阅读全文
一般的WEB应用如果是连ORACLE,要做连接池的话是在JAVA端用第三方的LIB,但对于MONGODB,官方已经有现成的实现,只需配置即可。
#控制系统在发生连接错误时是否重试 ,默认为false --boolean
mongo.options.autoConnectRetry=false
#每个主机允许的连接数(每个主机的连接池大小),当连接池被用光时,会被阻塞住 ,默认为10 --int
mongo.options.connectionsPerHost=10
#multiplier for connectionsPerHost for # of threads that can block if connectionsPerHost is 10, and threadsAllowedToBlockForConnectionMultiplier is 5, then 50 threads can block more than that and an exception will be throw --int
mongo.options.threadsAllowedToBlockForConnectionMultiplier=5
#被阻塞线程从连接池获取连接的最长等待时间(ms) --int
mongo.options.maxWaitTime
#在建立(打开)套接字连接时的超时时间(ms),默认为0(无限) --int
mongo.options.connectTimeout=0
#套接字超时时间;该值会被传递给Socket.setSoTimeout(int)。默认为0(无限) --int
mongo.options.socketTimeout=0
#This controls whether or not to have socket keep alive turned on (SO_KEEPALIVE). defaults to false --boolean
mongo.options.socketKeepAlive=false
#Override the DBCallback factory. Default is for the standard Mongo Java driver configuration --DBCallbackFactory
mongo.options.dbCallbackFactory
#//指明是否允许驱动从次要节点或者奴隶节点读取数据,默认为false --boolean
mongo.options.slaveOk=false
#如果为true,驱动每次update后会发出一个getLastError命令来保证成功,默认为false --boolean
mongo.options.safe=false
#If set, the w value of WriteConcern for the connection is set to this. Defaults to 0; implies safe = true --int
mongo.options.w=0
#If set, the wtimeout value of WriteConcern for the connection is set to this. Defaults to 0; implies safe = true --int
mongo.options.wtimeout=0
#Sets the fsync value of WriteConcern for the connection. Defaults to false; implies safe = true --boolean
mongo.options.fsync=false