• 大小: 12.3MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-26
  • 语言: 其他
  • 标签: zookeeper  

资源简介

Zookeeper 作为一个分布式的服务框架,主要用来解决分布式集群中应用系统的一致性问题,它能提供基于类似于文件系统的目录节点树方式的数据存储, Zookeeper 作用主要是用来维护和监控存储的数据的状态变化,通过监控这些数据状态的变化,从而达到基于数据的集群管理。

资源截图

代码片段和文件信息

package org.apache.bookkeeper.benchmark;

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */

import java.io.FileOutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;

import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.client.LedgerHandle;
import org.apache.bookkeeper.client.QuorumEngine;
import org.apache.log4j.Logger;


import org.apache.zookeeper.KeeperException;

public class MySqlClient {
static Logger LOG = Logger.getLogger(QuorumEngine.class);

BookKeeper x;
LedgerHandle lh;
Integer entryId;
HashMap map;

FileOutputStream fStream;
FileOutputStream fStreamLocal;
long start lastId;
Connection con;
Statement stmt;


public MySqlClient(String hostport String user String pass) 
throws ClassNotFoundException {
entryId = 0;
map = new HashMap();
Class.forName(“com.mysql.jdbc.Driver“);
// database is named “bookkeeper“
String url = “jdbc:mysql://“ + hostport + “/bookkeeper“;
try {
con = DriverManager.getConnection(url user pass);
stmt = con.createStatement();
// drop table and recreate it
stmt.execute(“DROP TABLE IF EXISTS data;“);
stmt.execute(“create table data(transaction_id bigint PRIMARY KEY AUTO_INCREMENT content TEXT);“);
LOG.info(“Database initialization terminated“);
} catch (SQLException e) {

// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void closeHandle() throws KeeperException InterruptedException SQLException{
con.close();
}
/**
 * First parameter is an integer defining the length of the message 
 * Second parameter is the number of writes
 * Third parameter is host:port 
 * Fourth parameter is username
 * Fifth parameter is password
 * @param args
 * @throws ClassNotFoundException 
 * @throws SQLException 
 */
public static void main(String[] args) throws ClassNotFoundException SQLException {
int lenght = Integer.parseInt(args[1]);
StringBuilder sb = new StringBuilder();
while(lenght-- > 0){
sb.append(‘a‘);
}
try {
MySqlClient c = new MySqlClient(args[2] args[3] args[4]);
c.writeSameEntryBatch(sb.toString

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\bin\
     文件         238  2012-07-29 14:23  zookeeper-3.3.6\bin\README.txt
     文件        1843  2012-07-29 14:23  zookeeper-3.3.6\bin\zkCleanup.sh
     文件        1049  2012-07-29 14:23  zookeeper-3.3.6\bin\zkCli.cmd
     文件        1446  2012-07-29 14:23  zookeeper-3.3.6\bin\zkCli.sh
     文件        1333  2012-07-29 14:23  zookeeper-3.3.6\bin\zkEnv.cmd
     文件        2274  2012-07-29 14:23  zookeeper-3.3.6\bin\zkEnv.sh
     文件        1084  2012-07-29 14:23  zookeeper-3.3.6\bin\zkServer.cmd
     文件        5130  2012-07-29 14:23  zookeeper-3.3.6\bin\zkServer.sh
     文件       59687  2012-07-29 14:23  zookeeper-3.3.6\build.xml
     文件       52566  2012-07-29 14:23  zookeeper-3.3.6\CHANGES.txt
     目录           0  2017-09-13 10:09  zookeeper-3.3.6\conf\
     文件         535  2012-07-29 14:23  zookeeper-3.3.6\conf\configuration.xsl
     文件        1698  2012-07-29 14:23  zookeeper-3.3.6\conf\log4j.properties
     文件         426  2017-09-12 18:20  zookeeper-3.3.6\conf\zoo.cfg
     文件         380  2012-07-29 14:23  zookeeper-3.3.6\conf\zoo.cfg.bak
     文件         380  2012-07-29 14:23  zookeeper-3.3.6\conf\zoo_sample.cfg_1
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\benchmark\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\benchmark\org\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\benchmark\org\apache\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\benchmark\org\apache\bookkeeper\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\benchmark\org\apache\bookkeeper\benchmark\
     文件        4669  2012-07-29 14:22  zookeeper-3.3.6\contrib\bookkeeper\benchmark\org\apache\bookkeeper\benchmark\MySqlClient.java
     文件        8359  2012-07-29 14:22  zookeeper-3.3.6\contrib\bookkeeper\benchmark\org\apache\bookkeeper\benchmark\TestClient.java
     文件        5937  2012-07-29 14:22  zookeeper-3.3.6\contrib\bookkeeper\build.xml
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\src\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\src\java\
     目录           0  2017-09-12 18:17  zookeeper-3.3.6\contrib\bookkeeper\src\java\org\
............此处省略1590个文件信息

评论

共有 条评论