引进2随上java书和PDF

操作系统 : CentOS7.3.1611_x64

推荐2依照学习java书和PDF下载地址

go语言版本:1.8.3 linux/amd64

《深入理解Java虚拟机:JVM高级特性以及最佳实践》共分为五大部分,围绕内存管理、执行子系统、程序编译和优化、高效并发等核心主题对JVM进行了周全而深刻的剖析,深刻揭示了JVM的办事原理。第一部分由本的角度介绍了整Java技术体系、Java和JVM的前进过程、模块化,以及JDK的编译,这对准晓本书后边内容产生主要援。第二片上书了JVM的全自动内存管理,包括虚拟机内存区域的分开原理和各种内存溢出深出的因;常见的污染源收集算法和垃圾收集器的特色和工作规律;常见虚拟机监控与故障处理工具的规律与运用方法。第三组成部分分析了虚拟机的执行子系统,包括类公事结构、虚拟机类加载机制、虚拟机字节码执行引擎。第四有的教书了先后的编译和代码的优化,阐述了泛型、自动装箱拆箱、条件编译等语法糖的原理;讲解了虚拟机的俏探测方法、HotSpot的就算经常编译器、编译触发条件,以及如何由虚拟机外部观察和分析JIT编译的数码以及结果;第五有追了Java实现迅速并发的规律,包括JVM内存模型的组织及操作;原子性、可见性和有序性在Java内存模型中的体现;先行来原则的平整与动;线程在Java语言中的贯彻原理;虚拟机实现高效并作所举行的相同文山会海锁优化措施。

InfluxDB版本:1.1.0

本书适合所有Java程序员、系统调优师和网架构师阅读。 

influxdb默认配置:

图片 1

/etc/influxdb/influxdb.conf

 

meta默认配置:

深深明Java虚拟机:JVM高级特性和超级实践 第2版本 高清PDF下载

[meta]
  dir = "/var/lib/influxdb/meta"
  retention-autocreate = true
  logging-enabled = true

百度网盘免费下载地址:http://pan.baidu.com/s/1jGxaP74

  • dir

源码+PDF展现下的总是

meta数据存放目录,默认值:/var/lib/influxdb/meta

——————————————分割线——————————————

meta数据文件默认路径:/var/lib/influxdb/meta/meta.db

FTP地址:ftp://ftp1.linuxidc.com

  • retention-autocreate

用户名:ftp1.linuxidc.com

用来控制默认存储策略,数据库创建时,会自动生成autogen的囤积策略,默认值:true

密码:www.linuxidc.com

  • logging-enabled

在 2014年LinuxIDC.com\9月\深切理解Java虚拟机:JVM高级特性以及最佳实践
第2版 高清PDF+源码

是不是打开meta日志,默认值:true

下载方式见 http://www.linuxidc.com/Linux/2013-10/91140.htm

meta文件的dump和load

源码路径: github.com/influxdata/influxdb/services/meta/client.go

meta文件dump

// snapshot will save the current meta data to disk
func snapshot(path string, data *Data) error {
    file := filepath.Join(path, metaFile)
    tmpFile := file + "tmp"

    f, err := os.Create(tmpFile)
    if err != nil {
        return err
    }
    defer f.Close()

    var d []byte
    if b, err := data.MarshalBinary(); err != nil {
        return err
    } else {
        d = b
    }

    if _, err := f.Write(d); err != nil {
        return err
    }

    if err = f.Sync(); err != nil {
        return err
    }

    //close file handle before renaming to support Windows
    if err = f.Close(); err != nil {
        return err
    }

    return renameFile(tmpFile, file)
}

snapshot可以经以下简单种方法触发:

1、当执行 Client.Open 函数时见面开展snapshot操作;

2、执行meta文件更新时经commit函数进行snapshot操作;

每当InfluxDB中程序中,通过 NewServer
函数创建MetaClient变量(meta.NewClient),然后实施MetaClient.Open()进行初始化;

接轨会透过Server.Open函数(run/server.go)启动各项服务,如果发meta文件之更新操作,通过commit函数进行snapshot操作;

meta文件load

// Load will save the current meta data from disk
func (c *Client) Load() error {
    file := filepath.Join(c.path, metaFile)

    f, err := os.Open(file)
    if err != nil {
        if os.IsNotExist(err) {
            return nil
        }
        return err
    }
    defer f.Close()

    data, err := ioutil.ReadAll(f)
    if err != nil {
        return err
    }

    if err := c.cacheData.UnmarshalBinary(data); err != nil {
        return err
    }
    return nil
}

Client.Open()中见面实行Load操作,NewServer时会自动加载。

——————————————分割线——————————————

meta文件内容编解码

源码路径: github.com/influxdata/influxdb/services/meta/data.go

meta数据encode:

// MarshalBinary encodes the metadata to a binary format.
func (data *Data) MarshalBinary() ([]byte, error) {
    return proto.Marshal(data.marshal())
}

meta数据decode:

// UnmarshalBinary decodes the object from a binary format.
func (data *Data) UnmarshalBinary(buf []byte) error {
    var pb internal.Data
    if err := proto.Unmarshal(buf, &pb); err != nil {
        return err
    }
    data.unmarshal(&pb)
    return nil
}

proto路径 :github.com/gogo/protobuf/proto

正文永久更新链接地址:http://www.linuxidc.com/Linux/2014-09/106869.htm

meta文件结构定义

源码路径: github.com/influxdata/influxdb/services/meta/data.go

meta文件存储的虽是 meta.Data 的数,结构定义如下:

// Data represents the top level collection of all metadata.
type Data struct {
    Term      uint64 // associated raft term
    Index     uint64 // associated raft index
    ClusterID uint64
    Databases []DatabaseInfo
    Users     []UserInfo

    MaxShardGroupID uint64
    MaxShardID      uint64
}

Term :暂时不清楚怎么用之。

Index
:从源码看是当是近乎版本号的物,初始化为1,执行commit操作是会见加。如果也1,会这施行持久化操作(在Open函数中操作)。

ClusterID : 是InfluxDB集群相关内容;

Databases :用于存储数据库信息;

Users :用于存储数据库用户信息;

DatabaseInfo 定义 :

// DatabaseInfo represents information about a database in the system.
type DatabaseInfo struct {
    Name                   string
    DefaultRetentionPolicy string
    RetentionPolicies      []RetentionPolicyInfo
    ContinuousQueries      []ContinuousQueryInfo
}

RetentionPolicyInfo 定义:

// RetentionPolicyInfo represents metadata about a retention policy.
type RetentionPolicyInfo struct {
    Name               string
    ReplicaN           int
    Duration           time.Duration
    ShardGroupDuration time.Duration
    ShardGroups        []ShardGroupInfo
    Subscriptions      []SubscriptionInfo
}

ShardGroupInfo 定义:

// ShardGroupInfo represents metadata about a shard group. The DeletedAt field is important
// because it makes it clear that a ShardGroup has been marked as deleted, and allow the system
// to be sure that a ShardGroup is not simply missing. If the DeletedAt is set, the system can
// safely delete any associated shards.
type ShardGroupInfo struct {
    ID          uint64
    StartTime   time.Time
    EndTime     time.Time
    DeletedAt   time.Time
    Shards      []ShardInfo
    TruncatedAt time.Time
}

ShardInfo 定义:

// ShardInfo represents metadata about a shard.
type ShardInfo struct {
    ID     uint64
    Owners []ShardOwner
}

ShardOwner 定义:

// ShardOwner represents a node that owns a shard.
type ShardOwner struct {
    NodeID uint64
}

ShardOwner主要用来集群,其中NodeId用于标识集群的节点ID,在InfluxDB
1.1社区本被集群已休支持了,该字段无效。

SubscriptionInfo 定义:

// SubscriptionInfo hold the subscription information
type SubscriptionInfo struct {
    Name         string
    Mode         string
    Destinations []string
}

ContinuousQueryInfo 定义:

// ContinuousQueryInfo represents metadata about a continuous query.
type ContinuousQueryInfo struct {
    Name  string
    Query string
}

UserInfo 定义:

// UserInfo represents metadata about a user in the system.
type UserInfo struct {
    Name       string
    Hash       string
    Admin      bool
    Privileges map[string]influxql.Privilege
}

 

其它

meta文件分析示例代码:

package main

import (
    "os"
    "fmt"
    "io/ioutil"
    "github.com/influxdata/influxdb/services/meta"
)

func Load(metaFile string) error {
    cacheData:= &meta.Data{
            Index: 1,
        }
    //file := filepath.Join(c.path, metaFile)

    f, err := os.Open(metaFile)
    if err != nil {
        if os.IsNotExist(err) {
            return nil
        }
        return err
    }
    defer f.Close()

    data, err := ioutil.ReadAll(f)
    if err != nil {
        return err
    }

    if err := cacheData.UnmarshalBinary(data); err != nil {
        return err
    }
    //fmt.Println(data)
    //fmt.Println("=======================")

    fmt.Println("Term       :",cacheData.Term)
    fmt.Println("Index      :",cacheData.Index)
    fmt.Println("Databases :")
    //fmt.Println(cacheData.Databases)

    for k,dbInfo := range cacheData.Databases {
        //fmt.Println(k,dbInfo)
        fmt.Println("k =",k)
        fmt.Println(dbInfo.Name,dbInfo.DefaultRetentionPolicy)
        for _,rPolicy := range dbInfo.RetentionPolicies {
            //fmt.Println(rPolicy)
            fmt.Println(rPolicy.Name,rPolicy.ReplicaN,rPolicy.Duration,rPolicy.ShardGroupDuration)
            fmt.Println("-------------ShardGroups---------------")
            //fmt.Println(rPolicy.ShardGroups)
            for shardIdx,shardGroup := range rPolicy.ShardGroups {
                //fmt.Println(shardGroup)
                fmt.Println("shardIdx =",shardIdx)
                fmt.Println("ID          :",shardGroup.ID)
                fmt.Println("StartTime   :",shardGroup.StartTime)
                fmt.Println("EndTime     :",shardGroup.EndTime)
                fmt.Println("DeletedAt   :",shardGroup.DeletedAt)
                //fmt.Println("Shards      :",shardGroup.Shards)
                fmt.Printf("Shards      :")
                for _,shard := range shardGroup.Shards {
                    fmt.Println(shard.ID,shard.Owners)
                }

                fmt.Println("TruncatedAt :",shardGroup.TruncatedAt)
                //fmt.Println(shardGroup.ID,shardGroup.StartTime,shardGroup.EndTime)
                // DeletedAt,Shards  ,      TruncatedAt
            }
            //fmt.Println(rPolicy.Subscriptions)
            fmt.Println("--------------Subscriptions----------------")
            for subsIdx,subInfo := range rPolicy.Subscriptions {
                //fmt.Println(subInfo)
                fmt.Println("subsIdx =",subsIdx)
                fmt.Println("Name :",subInfo.Name)
                fmt.Println("Mode :",subInfo.Mode)
                fmt.Println("Destinations :",subInfo.Destinations)
            }

        }
        fmt.Println("=======================")
    }

    fmt.Println("Users :")
    fmt.Println(cacheData.Users)
    fmt.Println(cacheData.MaxShardGroupID)
    fmt.Println(cacheData.MaxShardID)
    return nil
}

func main() {
    argsWithProg := os.Args
    if(len(argsWithProg) < 2) {
        fmt.Println("usage : ",argsWithProg[0]," configFile")
        return
    }
    metaFile := os.Args[1]

    fmt.Println(argsWithProg)
    fmt.Println(metaFile)

    Load(metaFile)
}

吓,就这些了,希望对君生出帮助。

本文github地址:

https://github.com/mike-zhang/mikeBlogEssays/blob/master/2018/20180112\_InfluxDB\_meta文件解析.rst

欢迎补充

 

仲、thinking in java 下充斥地址

http://vdisk.weibo.com/s/sYrOrIqygbN7

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图