这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name = "bayard"
version = "0.1.1"
authors = ["Minoru Osuka <minoru.osuka@gmail.com>"]
edition = "2018"
description = "Bayard is a full-text search and indexing server written in Rust."
documentation = "https://bayard-search.github.io/bayard/"
homepage = "https://github.com/bayard-search/bayard"
repository = "https://github.com/bayard-search/bayard"
readme = "README.md"
keywords = ["search", "index", "server", "information", "retrieval"]
categories = ["database"]
license = "MIT"

[lib]
name = "bayard"
Expand All @@ -13,6 +21,8 @@ path = "src/main.rs"

[dependencies]
clap = "2.33.0"
crossbeam-channel = "0.3.9"
ctrlc = { version = "3.1.3", features = ["termination"] }
env_logger = "0.7.0"
futures = "0.1.29"
grpcio = { version = "0.4.5", features = [ "secure" ] }
Expand Down
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
BIN_DIR ?= $(CURDIR)/bin
DATA_DIR ?= $(CURDIR)/data
CARGO_TARGET_DIR ?= $(CURDIR)/target
VERSION ?=

ifeq ($(VERSION),)
Expand All @@ -9,8 +7,7 @@ endif

clean:
rm -rf $(BIN_DIR)
rm -rf $(DATA_DIR)
rm -rf $(CARGO_TARGET_DIR)
cargo clean

format:
cargo fmt
Expand All @@ -19,20 +16,20 @@ protoc:
./generate_proto.sh

build:
mkdir -p $(BIN_DIR)
cargo update -p protobuf --precise 2.8.0
cargo build --release
mkdir -p $(BIN_DIR)
cp $(CARGO_TARGET_DIR)/release/bayard $(BIN_DIR)/
cp -p ./target/release/bayard $(BIN_DIR)

docker-build:
build-docker:
docker build -t bayardsearch/bayard:latest .
docker tag bayardsearch/bayard:latest bayardsearch/bayard:$(VERSION)

docker-push:
push-docker:
docker push bayardsearch/bayard:latest
docker push bayardsearch/bayard:$(VERSION)

docker-clean:
clean-docker:
docker rmi -f $(shell docker images --filter "dangling=true" -q --no-trunc)

build-docs:
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Bayard makes easy for programmers to develop search applications with advanced f
- Command line interface is available


## Source code
## Source code repository

Here is the source code.
- [https://github.com/bayard-search/bayard](https://github.com/bayard-search/bayard)

## Docker container repository

- [https://hub.docker.com/r/bayardsearch/bayard](https://hub.docker.com/r/bayardsearch/bayard)

## Documents

The document is available at the following URL:
- [https://bayard-search.github.io/bayard/](https://bayard-search.github.io/bayard/)
8 changes: 5 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ <h2><a class="header" href="#features" id="features">Features</a></h2>
<li>Bringing up a cluster</li>
<li>Command line interface is available</li>
</ul>
<h2><a class="header" href="#source-code" id="source-code">Source code</a></h2>
<p>Here is the source code.</p>
<h2><a class="header" href="#source-code-repository" id="source-code-repository">Source code repository</a></h2>
<ul>
<li><a href="https://github.com/bayard-search/bayard">https://github.com/bayard-search/bayard</a></li>
</ul>
<h2><a class="header" href="#docker-container-repository" id="docker-container-repository">Docker container repository</a></h2>
<ul>
<li><a href="https://hub.docker.com/r/bayardsearch/bayard">https://hub.docker.com/r/bayardsearch/bayard</a></li>
</ul>
<h2><a class="header" href="#documents" id="documents">Documents</a></h2>
<p>The document is available at the following URL:</p>
<ul>
<li><a href="https://bayard-search.github.io/bayard/">https://bayard-search.github.io/bayard/</a></li>
</ul>
Expand Down
8 changes: 5 additions & 3 deletions docs/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ <h2><a class="header" href="#features" id="features">Features</a></h2>
<li>Bringing up a cluster</li>
<li>Command line interface is available</li>
</ul>
<h2><a class="header" href="#source-code" id="source-code">Source code</a></h2>
<p>Here is the source code.</p>
<h2><a class="header" href="#source-code-repository" id="source-code-repository">Source code repository</a></h2>
<ul>
<li><a href="https://github.com/bayard-search/bayard">https://github.com/bayard-search/bayard</a></li>
</ul>
<h2><a class="header" href="#docker-container-repository" id="docker-container-repository">Docker container repository</a></h2>
<ul>
<li><a href="https://hub.docker.com/r/bayardsearch/bayard">https://hub.docker.com/r/bayardsearch/bayard</a></li>
</ul>
<h2><a class="header" href="#documents" id="documents">Documents</a></h2>
<p>The document is available at the following URL:</p>
<ul>
<li><a href="https://bayard-search.github.io/bayard/">https://bayard-search.github.io/bayard/</a></li>
</ul>
Expand Down
12 changes: 7 additions & 5 deletions docs/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,15 @@ <h2><a class="header" href="#features" id="features">Features</a></h2>
<li>Bringing up a cluster</li>
<li>Command line interface is available</li>
</ul>
<h2><a class="header" href="#source-code" id="source-code">Source code</a></h2>
<p>Here is the source code.</p>
<h2><a class="header" href="#source-code-repository" id="source-code-repository">Source code repository</a></h2>
<ul>
<li><a href="https://github.com/bayard-search/bayard">https://github.com/bayard-search/bayard</a></li>
</ul>
<h2><a class="header" href="#docker-container-repository" id="docker-container-repository">Docker container repository</a></h2>
<ul>
<li><a href="https://hub.docker.com/r/bayardsearch/bayard">https://hub.docker.com/r/bayardsearch/bayard</a></li>
</ul>
<h2><a class="header" href="#documents" id="documents">Documents</a></h2>
<p>The document is available at the following URL:</p>
<ul>
<li><a href="https://bayard-search.github.io/bayard/">https://bayard-search.github.io/bayard/</a></li>
</ul>
Expand Down Expand Up @@ -366,9 +368,9 @@ <h2><a class="header" href="#remove-a-server-from-a-cluster" id="remove-a-server
--leader-id=1
</code></pre>
<h1><a class="header" href="#running-on-docker" id="running-on-docker">Running on Docker</a></h1>
<p>Docker container image is available. Check the available version at the following URL:</p>
<p>See the available Docker container image version at the following URL:</p>
<ul>
<li>https://hub.docker.com/r/bayardsearch/bayard/tags/</li>
<li><a href="https://hub.docker.com/r/bayardsearch/bayard/tags/">https://hub.docker.com/r/bayardsearch/bayard/tags/</a></li>
</ul>
<h2><a class="header" href="#pulling-docker-container" id="pulling-docker-container">Pulling Docker container</a></h2>
<p>You can pull the Docker container image with the following command:</p>
Expand Down
4 changes: 2 additions & 2 deletions docs/running_on_docker.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ <h1 class="menu-title">Bayard</h1>
<div id="content" class="content">
<main>
<h1><a class="header" href="#running-on-docker" id="running-on-docker">Running on Docker</a></h1>
<p>Docker container image is available. Check the available version at the following URL:</p>
<p>See the available Docker container image version at the following URL:</p>
<ul>
<li>https://hub.docker.com/r/bayardsearch/bayard/tags/</li>
<li><a href="https://hub.docker.com/r/bayardsearch/bayard/tags/">https://hub.docker.com/r/bayardsearch/bayard/tags/</a></li>
</ul>
<h2><a class="header" href="#pulling-docker-container" id="pulling-docker-container">Pulling Docker container</a></h2>
<p>You can pull the Docker container image with the following command:</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs_src/building_bayard.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ When the build is successful, the binary file is output to the following directo
```text
$ ls ./bin
```


4 changes: 2 additions & 2 deletions docs_src/running_on_docker.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Running on Docker

Docker container image is available. Check the available version at the following URL:
- https://hub.docker.com/r/bayardsearch/bayard/tags/
See the available Docker container image version at the following URL:
- [https://hub.docker.com/r/bayardsearch/bayard/tags/](https://hub.docker.com/r/bayardsearch/bayard/tags/)

## Pulling Docker container

Expand Down
5 changes: 3 additions & 2 deletions src/cmd/leave.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use std::collections::HashMap;

use clap::ArgMatches;
use log::*;
use raft::eraftpb::{ConfChange, ConfChangeType};

use crate::client::client::{create_client, Clerk};
use crate::client::client::create_client;
use crate::proto::indexrpcpb::ConfChangeReq;
use crate::server::util::conf_change;
use crate::util::log::set_log_level;
use std::collections::HashMap;

pub fn run_leave_cli(matches: &ArgMatches) -> Result<(), String> {
set_log_level();
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn run_search_cli(matches: &ArgMatches) -> Result<(), String> {
set_log_level();
env_logger::init();

let servers: Vec<_> = matches
let servers: Vec<_> = matches
.values_of("SERVERS")
.unwrap()
.map(|addr| create_client(addr))
Expand Down
14 changes: 7 additions & 7 deletions src/server/peer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
//use std::collections::HashMap;
use std::sync::mpsc::{Receiver, RecvTimeoutError, SyncSender};
use std::thread;
use std::time::{Duration, Instant};
Expand All @@ -18,10 +18,10 @@ pub enum PeerMessage {

pub struct Peer {
raft_group: RawNode<PeerStorage>,
last_applying_idx: u64,
last_compacted_idx: u64,
// last_applying_idx: u64,
// last_compacted_idx: u64,
apply_ch: SyncSender<Entry>,
peers_addr: HashMap<u64, (String, u32)>,
// peers_addr: HashMap<u64, (String, u32)>,
}

impl Peer {
Expand All @@ -30,10 +30,10 @@ impl Peer {
let storge = PeerStorage::new();
Peer {
raft_group: RawNode::new(&cfg, storge, vec![]).unwrap(),
last_applying_idx: 0,
last_compacted_idx: 0,
// last_applying_idx: 0,
// last_compacted_idx: 0,
apply_ch,
peers_addr: HashMap::new(),
// peers_addr: HashMap::new(),
}
}

Expand Down
31 changes: 22 additions & 9 deletions src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;

use futures::sync::oneshot;
use crossbeam_channel::{bounded, select, Receiver as CReceiver};
use ctrlc;
use futures::Future;
use grpcio::{ChannelBuilder, EnvBuilder, Environment, RpcContext, ServerBuilder, UnarySink};
use log::*;
Expand All @@ -24,6 +25,16 @@ use crate::server::{peer, util};

struct NotifyArgs(u64, String, RespErr);

fn sigterm_channel() -> Result<CReceiver<()>, ctrlc::Error> {
let (sender, receiver) = bounded(100);
ctrlc::set_handler(move || {
let _ = sender.send(());
})
.unwrap();

Ok(receiver)
}

#[derive(Clone)]
pub struct IndexServer {
id: u64,
Expand Down Expand Up @@ -78,15 +89,17 @@ impl IndexServer {
info!("listening on {}:{}", host, port);
}

let (tx, rx) = oneshot::channel();
thread::spawn(move || {
loop {
thread::sleep(Duration::from_secs(60));
// Wait for signals for termination (SIGINT, SIGTERM).
let sigterm_receiver = sigterm_channel().unwrap();
loop {
select! {
recv(sigterm_receiver) -> _ => {
info!("stopping on {}:{}", host, port);
let _ = server.shutdown().wait();
break;
}
}
tx.send(())
});
let _ = rx.wait();
let _ = server.shutdown().wait();
}
}

fn async_rpc_sender(&mut self, receiver: Receiver<RaftMessage>) {
Expand Down