q16 版.
安装后,把所有的dll 拷贝到system32.



posted @ 2007-09-22 08:48 西津渡| 编辑 收藏
 
经过一段时间的折腾。一堆东西能避免使用就避免使用。


castor, dwr, acegi, 几乎扔掉。

spring ,hibernate 也只用在适当的场合。

struts2 ,也只用在适当的场合。


一些偷懒的技术,尽量避免。
opensession in view.

posted @ 2007-09-14 15:52 西津渡 阅读(199) | 评论 (0)编辑 收藏
 

一直困扰于 indexSearcher 的重新 new ,query filter 的cache 没了。

重读solr ,发现非常好。也许我应该考虑用 solr 了。


Caching

  • Configurable Query Result, Filter, and Document cache instances
  • Pluggable Cache implementations
  • Cache warming in background
    • When a new searcher is opened, configurable searches are run against it in order to warm it up to avoid slow first hits. During warming, the current searcher handles live requests.
  • Autowarming in background
    • The most recently accessed items in the caches of the current searcher are re-populated in the new searcher, enabing high cache hit rates across index/searcher changes.
  • Fast/small filter implementation
  • User level caching with autowarming support
9-26
  今天,我发现,我可以用不同的方式实现cache ,也许在我的情况下比solr 的方式更好。
posted @ 2007-09-07 17:18 西津渡 阅读(255) | 评论 (0)编辑 收藏
 
在一台 8G ,2 dual core cpu 的2u , struts2+spring+hibernate .
开源软件,用什么样的 proxy, cache, web container 达到最好的性能。

瓶颈在于:
 tomcat 只能用到2g ram

经过研究,
xmx 在windows 2003,jdk1.5.06 ,1999M.
所以如果是一台单纯的web container server 就不要搞8G了, 1U 的4G ok.

需要用到那么高的性能场景,只能是两台1U做 banlance.

再次研究
用 session stick ,balance 2 个 tomcat ,应该可以达到较好的性能。

posted @ 2007-09-06 20:55 西津渡 阅读(219) | 评论 (0)编辑 收藏
 
环境  apache + tomcat , ajp 连接。
 apr
 jvm 优化
 nio , connector 优化。
 c3p0.
情况下
用jmeter ,tomcat 到 1000 并发没有问题。


发现一个问题: apache 的 250 个 worker 限制。

导致单纯的 tomcat 性能更好。比用ajp.


一个 threadgroup, 3个http sample, 1000 ,5428。

看来,需要编译 apache.


posted @ 2007-09-06 15:31 西津渡 阅读(222) | 评论 (0)编辑 收藏
 
http://www.mchange.com/projects/c3p0/#configuration_properties


spring+hibernate
   
连接池

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
  
    
     <property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/openfire"/>
<property name="user" value="root"/>
<property name="password" value="password"/>
   
    </bean>
   
   
</beans>

tomcat jndi:

<Resource auth="Container" description="DB Connection" driverClass="com.mysql.jdbc.Driver" maxPoolSize="4" minPoolSize="2" acquireIncrement="1" name="jdbc/TestDB" user="test" password="ready2go" factory="org.apache.naming.factory.BeanFactory" type="com.mchange.v2.c3p0.ComboPooledDataSource" jdbcUrl="jdbc:mysql://localhost:3306/test?autoReconnect=true" />






建议:c3p0.propertyies

c3p0.acquireIncrement=5       
c3p0.idleConnectionTestPeriod=1800   
c3p0.initialPoolSize=5       
c3p0.maxIdleTime=1000
c3p0.maxPoolSize=20   
c3p0.maxStatements=100   
c3p0.minPoolSize=5


just hibernate:
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider


调优:在我的环境下
maxpoolSize 30, 1822 , 15, 1655 。 可能和测试过程有关。
maxStatement 加上, 3600。严重影响性能。

扩大 xms xmx 512 ,957


posted @ 2007-09-06 13:16 西津渡 阅读(469) | 评论 (0)编辑 收藏
 
tree 结构很常见,当persist 到数据库中。

有些操作,在db 中更好。

1。取得所有的叶子节点。

SELECT Name FROM Projects p WHERE NOT EXISTS( SELECT * FROM Projects WHERE Parent=p.VertexId)

2。multilevel operation ,用数据库的辅助表, 用triger 。
CREATE TABLE ProjectPaths(

VertexId INTEGER,

Depth INTEGER,

Path VARCHAR(300) 。



)
3. 用 hibernate 时,如果 stack over flow,考虑用 stack 代替recursive algrithm

public void traverseDepthFirst( AST ast )
{
// Root AST node cannot be null or
// traversal of its subtree is impossible.
if ( ast == null )
{
throw new IllegalArgumentException(
"node to traverse cannot be null!" );
}
// Map to hold parents of each
// AST node. Unfortunately the AST
// interface does not provide a method
// for finding the parent of a node, so
// we use the Map to save them.

Map parentNodes = new HashMap();

// Start tree traversal with first child
// of the specified root AST node.

AST currentNode = ast.getFirstChild();

// Remember parent of first child.

parentNodes.put( currentNode , ast );

// Iterate through nodes, simulating
// recursive tree traversal, and add them
// to queue in proper order for later
// linear traversal. This "flattens" the
// into a linear list of nodes which can
// be visited non-recursively.

while ( currentNode != null )
{
// Visit the current node.

strategy.visit( currentNode );

// Move down to current node's first child
// if it exists.

AST childNode = currentNode.getFirstChild();

// If the child is not null, make it
// the current node.

if ( childNode != null )
{
// Remember parent of the child.

parentNodes.put( childNode , currentNode );

// Make child the current node.

currentNode = childNode;

continue;
}

while ( currentNode != null )
{
// Move to next sibling if any.

AST siblingNode = currentNode.getNextSibling();

if ( siblingNode != null )
{
// Get current node's parent.
// This is also the parent of the
// sibling node.

AST parentNode = (AST)parentNodes.get( currentNode );

// Remember parent of sibling.

parentNodes.put( siblingNode , parentNode );

// Make sibling the current node.

currentNode = siblingNode;

break;
}
// Move up to parent if no sibling.
// If parent is root node, we're done.

currentNode = (AST)parentNodes.get( currentNode );

if ( currentNode.equals( ast ) )
{
currentNode = null;
}
}
}




参考:

http://wordhoard.northwestern.edu/userman/hibernatechanges.html

《Tansact Sql cookbook.》






posted @ 2007-09-05 14:18 西津渡 阅读(468) | 评论 (0)编辑 收藏
 
一、one-many ,需要一个有序的list. 建议影射方式 :

private List _items;

<bag
name="items"
inverse="true"   //尽量使用双向关联
order-by="DATE_TIME"
cascade="all">
<key column="BLOG_ID"/>
<one-to-many class="BlogItem"/>
</bag>


many-to-many ,建议用 set



二、one-to-one 适用
            通过主键进行关联
            相当于把大表拆分为多个小表
            例如把大字段单独拆分出来,以提高数据库操作的性能

三、composite element ,必须依赖的导航关系

 <list name="lineItems" table="line_items">
<key column="order_id"/>
<list-index column="line_number"/>
<composite-element class="LineItem">
<property name="quantity"/>
<many-to-one name="product" column="product_id"/>
</composite-element>
</list>

四、 one-one formula , 很复杂,有点不明白

 <class name="Person">
<id name="name"/>
<one-to-one name="address"
cascade="all">
<formula>name</formula>
<formula>'HOME'</formula>
</one-to-one>
<one-to-one name="mailingAddress"
cascade="all">
<formula>name</formula>
<formula>'MAILING'</formula>
</one-to-one>
</class>
<class name="Address" batch-size="2"
check="addressType in ('MAILING', 'HOME', 'BUSINESS')">
<composite-id>
<key-many-to-one name="person"
column="personName"/>
<key-property name="type"
column="addressType"/>
</composite-id>
<property name="street" type="text"/>
<property name="state"/>
<property name="zip"/>
</class>


五、继承关系, per subclass table ,no discriminator ,joined-subclass




六、tree
拷贝: http://www.thogau.net/tutorials/tree/tutorial02-01.jsp


package net.thogau.website.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * This class implements a persisted tree node.
 *
 * @author <a href="mailto:thogau@thogau.net">thogau</a>
 *
 * @struts.form include-all="false" extends="BaseForm"
 * @hibernate.class table="node"
 */
public class Node extends BaseObject implements Serializable {
   
    // mapped to primary key in node table
    protected Long id;
       
    protected String name;
   
    protected Node parent = null;
   
    protected List children = new ArrayList();
   
    /**
     * @hibernate.id column="id" generator-class="native" unsaved-value="null"
     * @struts.form-field
     */
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }   
   
    /**
     * Returns the node name.
     *
     * @return String
     *
     * @hibernate.property column="name" not-null="true" unique="true"
     * @struts.form-field
     * @struts.validator type="required"
     *
     */
    public String getName() {
        return name;
    }  
    public void setName(String name) {
        this.name = name;
    }
   
    /**
     * Returns the node's children.
     *
     * @return List
     *
     * @hibernate.list cascade="all-delete-orphan" inverse="true"
     * @hibernate.collection-one-to-many class="net.thogau.website.model.Node"
     * @hibernate.collection-index column="position"
     * @hibernate.collection-key column="parent_id"
     * @struts.form-field
     */
    public List getChildren() {
        return children;
    }

    public void setChildren(List children) {
        this.children = children;
    }
   
    /**
     * Returns the position of the node in the children list (if it has parent).
     * @return int
     *
     * @hibernate.property column="position"
     */   
    public int getPosition() {
        try{
            return parent.getChildren().indexOf(this);
        }
        catch(NullPointerException e){
            // if it has no parent, position makes no sense
            return -1;
        }
    }
   
    public void setPosition(int position) { /* not used */ }
   
    /**
     * Returns the node's parent.
     *
     * @return Node
     *
     * @hibernate.many-to-one column = "parent_id" class="net.thogau.website.model.Node" cascade = "none"
     * @hibernate.column name="parent_id"
     */
     public Node getParent() {
        return parent;
    }
    
    public void setParent(Node n) {
        this.parent = n;
    }
   
    /**
     * @see java.lang.Object#equals(Object)
     */
    public boolean equals(Object object) {
        if (!(object instanceof Node)) {
            return false;
        }
        Node rhs = (Node) object;
        return new EqualsBuilder().append(this.name, rhs.name).append(
                this.children, rhs.children).append(this.parent, rhs.parent)
                .append(this.id, rhs.id).isEquals();
    }
   
    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode() {
        return new HashCodeBuilder(1036586079, -537109207).append(this.name)
                .append(this.parent.getName()).append(this.id)
                .toHashCode();
    }
   
    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("name", this.name).append("parent", this.parent)
                .append("id", this.id).append("position", this.getPosition()).toString();
    }
   
}

好像,equal ,hash 是必须的。

# /**
#      * 树形遍历
#      * 不用递归,用堆栈.
#      * 这里只是做为例子,本人不建议把业务逻辑封装在Entity层.
#                 */ 
#     public List getVisitResults() { 
#         List l = new ArrayList(); 
#         Stack s = new Stack(); 
#         s.push(this); 
#         while (s.empty() == false) { 
#            Cat c = (Cat) s.pop(); 
#            l.add(c); 
#            List children = c.getChildren(); 
#               if (children != null) { 
#                  for (int i = 0; i <  hildren.size(); i++)   { 
#             Cat cat = (Cat) children.get(i); 
#             s.push(cat); 
#                  }//end for 
#              }//end if 
#         }//end while 
#         return l; 
#     } 






 







posted @ 2007-09-05 12:11 西津渡 阅读(599) | 评论 (0)编辑 收藏
 
searcher 新开后,cache 会失效。
所以,重新开 searcher 的频率对于很重的访问量来说,不能太频繁。这样查询肯定有不能同步的问题。

对于不要求同步的场景来说,够了。
继续研究。





posted @ 2007-09-04 14:00 西津渡 阅读(225) | 评论 (0)编辑 收藏
 
在 conf/catalina/localhost/ 建 solr.xml

jndi solr/home :

<Context docBase="D:\sourcecode\apache-solr\dist\solr.war" debug="0" crossContext="true" >
   <Environment name="solr/home" type="java.lang.String" value="D:\sourcecode\solr-sample\solr" override="true" />
</Context>

solr/home 的结构
conf
data/index

posted @ 2007-09-04 13:53 西津渡 阅读(320) | 评论 (0)编辑 收藏
仅列出标题
共11页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last