q16 版.
          安裝后,把所有的dll 拷貝到system32.



          posted @ 2007-09-22 08:48 西津渡| 編輯 收藏
           
          經過一段時間的折騰。一堆東西能避免使用就避免使用。


          castor, dwr, acegi, 幾乎扔掉。

          spring ,hibernate 也只用在適當的場合。

          struts2 ,也只用在適當的場合。


          一些偷懶的技術,盡量避免。
          opensession in view.

          posted @ 2007-09-14 15:52 西津渡 閱讀(216) | 評論 (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 西津渡 閱讀(271) | 評論 (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 西津渡 閱讀(258) | 評論 (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 西津渡 閱讀(233) | 評論 (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 西津渡 閱讀(486) | 評論 (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 西津渡 閱讀(490) | 評論 (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 西津渡 閱讀(614) | 評論 (0)編輯 收藏
           
          searcher 新開后,cache 會失效。
          所以,重新開 searcher 的頻率對于很重的訪問量來說,不能太頻繁。這樣查詢肯定有不能同步的問題。

          對于不要求同步的場景來說,夠了。
          繼續研究。





          posted @ 2007-09-04 14:00 西津渡 閱讀(241) | 評論 (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 西津渡 閱讀(335) | 評論 (0)編輯 收藏
          僅列出標題
          共11頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 Last 
           
          主站蜘蛛池模板: 甘南县| 博白县| 靖州| 哈尔滨市| 龙井市| 来安县| 内江市| 洪湖市| 调兵山市| 嵩明县| 舟曲县| 玉田县| 兴安县| 澄江县| 黔东| 新宾| 汉阴县| 巧家县| 得荣县| 巴塘县| 长岛县| 栖霞市| 武川县| 蒲城县| 镇巴县| 成武县| 嫩江县| 读书| 朝阳区| 蒙阴县| 新竹县| 南平市| 太白县| 寿宁县| 慈利县| 女性| 左云县| 河南省| 陆丰市| 阿拉尔市| 天峨县|