Skip to content

Commit

Permalink
fix: first time setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ActivePeter committed Jun 16, 2024
1 parent 52ca0fb commit b23aaab
Show file tree
Hide file tree
Showing 16 changed files with 454 additions and 61 deletions.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions demos/_java_serverless_lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4.CRAC</version>
<version>3.2.4</version>
</parent>

<modules>
Expand All @@ -26,11 +26,11 @@

<dependencyManagement>
<dependencies>
<dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>3.2.4.CRAC</version>
</dependency>
<version>3.2.4</version>
</dependency> -->
<dependency>
<groupId>io.serverless_lib</groupId>
<artifactId>serverless-lib-core</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions demos/java_web/stock-mng/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
<artifactId>serverless-lib-core</artifactId>
<!-- <version>0.0.1-SNAPSHOT</version> -->
</dependency>
<dependency>
<!-- <dependency>
<groupId>io.sofastack</groupId>
<artifactId>balance-mng-facade</artifactId>
<version>${project.version}</version>
</dependency>
</dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.sofastack.balance.manage.facade.BalanceMngFacade;
// import io.sofastack.balance.manage.facade.BalanceMngFacade;
import io.sofastack.stockmng.controller.BookStoreController;
import io.sofastack.stockmng.facade.StockMngFacade;
import io.sofastack.stockmng.model.BalanceResponse;
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/1.1build_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ def print_title(title):
os_system_sure("mkdir -p pack/waverless_backend")
BACKEND_PATH=os.path.abspath("pack/waverless_backend")
os.chdir("../../")
os_system_sure("cargo build --release")
os_system_sure("$HOME/.cargo/bin/cargo build --release")
os_system_sure(f"cp target/release/wasm_serverless {BACKEND_PATH}")
6 changes: 5 additions & 1 deletion scripts/build/1.2build_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def pack_demo(app):
os.chdir(prj_dir)
# check Cargo.toml in the current directory
if os.path.exists("Cargo.toml"):
os_system_sure("cargo build --target wasm32-wasi --release")
os_system_sure("$HOME/.cargo/bin/cargo build --target wasm32-wasi --release")
elif os.path.exists("pom.xml"):
os_system_sure("mvn clean package")
else:
Expand Down Expand Up @@ -149,6 +149,10 @@ def open_app_conf(app):
type: SOCKET
action: close""")

# install java lib
os.chdir("../../demos/_java_serverless_lib")
os_system_sure("mvn clean install")

for app in DEMOS:
os.chdir(CUR_FDIR)
pack_demo(app)
2 changes: 2 additions & 0 deletions scripts/build/1.4pack_with_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ def cp_except(src, dest, exclude_list):

os_system_sure("rm -rf pack/waverless_ui")

os_system_sure("mkdir -p pack/waverless_ui")

cp_except("../../waverless_ui", "pack/waverless_ui", ["dist", "node_modules"])

4 changes: 3 additions & 1 deletion scripts/install/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
WasmEdge-0.13.3-manylinux2014_x86_64.tar.gz
WasmEdge-0.13.3-manylinux2014_x86_64.tar.gz
WasmEdge-0.13.3-manylinux2014_x86_64.tar.gz.1
llvm.sh
3 changes: 2 additions & 1 deletion scripts/install/2.1install_wasmedge.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def print_title(title):
VERSION="0.13.3"
TARGZ_FILE = f"WasmEdge-{VERSION}-manylinux2014_x86_64.tar.gz"
if not os.path.exists(f"/tmp/install/{TARGZ_FILE}"):
os_system_sure("mkdir -p /tmp/install/")
os_system_sure(f"wget https://github.com/WasmEdge/WasmEdge/releases/download/{VERSION}/{TARGZ_FILE}")
os_system_sure(f"mv {TARGZ_FILE} /tmp/install/")

Expand All @@ -47,7 +48,7 @@ def print_title(title):

print_title("debug wasmedge")
os_system_sure("ls /root/.wasmedge/bin/")
os_system_sure("wasmedge --version")
os_system_sure("/root/.wasmedge/bin/wasmedge --version")
# - name: Install WasmEdge
# become: true
# shell: |
Expand Down
42 changes: 42 additions & 0 deletions scripts/install/2.3install_java_related.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
### chdir
import os
import sys
import yaml
import zipfile

CUR_FPATH = os.path.abspath(__file__)
CUR_FDIR = os.path.dirname(CUR_FPATH)
# chdir to the directory of this script
os.chdir(CUR_FDIR)

# os.system('ansible-playbook -vv 2.ans_install_build.yml -i ../local_ansible_conf.ini')
### utils
def os_system_sure(command):
print(f">>> Run:{command}")
result = os.system(command)
if result != 0:
print(f">>> Fail:{command}\n\n")
exit(1)
print(f">>> Succ:{command}\n\n")


# result.returncode
# result.stdout
def run_cmd_return(cmd):
print(f"Run:{cmd}")
result = subprocess.run(command, shell=True, capture_output=True, text=True)
print(f"Stdout:{result.stdout}\n\n")
return result


def print_title(title):
print(f"\n\n>>> {title}")
#################################################################################################

os_system_sure("python3 inner/install_maven.py")

CRAC_INSTALL_DIR = "/usr/jdk_crac"
if not os.path.exists(CRAC_INSTALL_DIR):
os_system_sure("python3 inner/install_crac.py")

os_system_sure("python3 inner/switch_jdk_17crac.py")
4 changes: 2 additions & 2 deletions scripts/install/2.install_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def run_cmd_return(cmd):
os_system_sure("python3 2.2install_clang.py")


res=run_cmd_return("rustc --version")
res=run_cmd_return("$HOME/.cargo/bin/rustc --version")
if res.returncode != 0:
print("Rust not installed, installing now...")
os_system_sure("curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y")
# os_system_sure("source $HOME/.cargo/env")
os_system_sure("rustup target add wasm32-wasi")
os_system_sure("$HOME/.cargo/bin/rustup target add wasm32-wasi")
# os_system_sure("export PATH=$HOME/.cargo/bin:$PATH")


Expand Down
5 changes: 4 additions & 1 deletion scripts/install/inner/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
WasmEdge-0.13.3-manylinux2014_x86_64.tar.gz
WasmEdge-0.13.3-manylinux2014_x86_64.tar.gz
apache-maven-3.9.6-bin.tar.gz
apache-maven-3.9.6
crac
78 changes: 78 additions & 0 deletions scripts/install/inner/install_crac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

### chdir
import os
CUR_FPATH = os.path.abspath(__file__)
CUR_FDIR = os.path.dirname(CUR_FPATH)
# chdir to the directory of this script
os.chdir(CUR_FDIR)


### utils
def os_system_sure(command):
print(f"执行命令:{command}")
result = os.system(command)
if result != 0:
print(f"命令执行失败:{command}")
exit(1)
print(f"命令执行成功:{command}")


CRAC_INSTALL_DIR = "/usr/jdk_crac"



def compile_crac():
os_system_sure("apt install build-essential autoconf openjdk-17-jdk -y")
os.system("git clone https://github.com/ActivePeter/crac")
os.chdir("crac")
os_system_sure("git checkout sofacrac17")
installs=[
'libfontconfig1-dev',
'libx11-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev',
'zip unzip',
'file',
'build-essential',
'libasound2-dev',
'libcups2-dev'
]

os_system_sure("apt update")
os_system_sure("apt install {} -y".format(" ".join(installs)))

bins=[
"java",
"javac",
"jcmd"
]
OPENJDK="/usr/lib/jvm/java-17-openjdk-amd64/"
# swicth back to openjdk
for bin in bins:
# os_system_sure(f"update-alternatives --install /usr/bin/{bin} {bin} {OPENJDK}bin/{bin} 1")
os_system_sure(f"update-alternatives --set {bin} {OPENJDK}bin/{bin}")

os_system_sure("bash configure")
os_system_sure("make images")
CRIU_PATH = "build/linux-x86_64-server-release/images/jdk/lib/criu"
if not os.path.exists(CRIU_PATH):
os_system_sure("wget https://github.com/CRaC/criu/releases/download/release-crac/criu-dist.tar.gz")
os_system_sure("tar -zxvf criu-dist.tar.gz")
os_system_sure(f"cp criu-dist/sbin/criu {CRIU_PATH}")

os_system_sure("rm -rf {}".format(CRAC_INSTALL_DIR))
os_system_sure(f"cp -r build/linux-x86_64-server-release/images/jdk/ {CRAC_INSTALL_DIR}")
# switch to crac jdk

for bin in bins:
os_system_sure(f"update-alternatives --install /usr/bin/{bin} {bin} {CRAC_INSTALL_DIR}/bin/{bin} 100")
os_system_sure(f"update-alternatives --set {bin} {CRAC_INSTALL_DIR}/bin/{bin}")




def download_crac_bin():
if not os.path.exists("./bellsoft-jdk17.0.10+14-linux-amd64-crac.deb"):
os_system_sure("wget https://download.bell-sw.com/java/17.0.10+14/bellsoft-jdk17.0.10+14-linux-amd64-crac.deb")

os_system_sure("dpkg -i bellsoft-jdk17.0.10+14-linux-amd64-crac.deb")

compile_crac()
52 changes: 52 additions & 0 deletions scripts/install/inner/install_maven.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

### chdir
import os
CUR_FPATH = os.path.abspath(__file__)
CUR_FDIR = os.path.dirname(CUR_FPATH)
# chdir to the directory of this script
os.chdir(CUR_FDIR)


### utils
def os_system_sure(command):
print(f"执行命令:{command}")
result = os.system(command)
if result != 0:
print(f"命令执行失败:{command}")
exit(1)
print(f"命令执行成功:{command}")



if os.path.exists("apache-maven-3.9.6-bin.tar.gz"):
print("maven已存在,无需再次下载")
else:
os_system_sure("wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz")



if os.path.exists("apache-maven-3.9.6"):
print("maven已解压,无需再次解压")
else:
os_system_sure("tar -zxvf apache-maven-3.9.6-bin.tar.gz")



MAVEN="/usr/lib/mvn"
os_system_sure("mkdir -p "+MAVEN)
os_system_sure("cp -r apache-maven-3.9.6 "+MAVEN)



bins=[
"mvn",
"mvnDebug",
"mvnyjp",
]



for bin in bins:
os_system_sure(f"update-alternatives --install /usr/bin/{bin} {bin} {MAVEN}/apache-maven-3.9.6/bin/{bin} 1")
os_system_sure(f"update-alternatives --set {bin} {MAVEN}/apache-maven-3.9.6/bin/{bin}")

50 changes: 50 additions & 0 deletions scripts/install/inner/switch_jdk_17crac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

### chdir
import os
CUR_FPATH = os.path.abspath(__file__)
CUR_FDIR = os.path.dirname(CUR_FPATH)
# chdir to the directory of this script
os.chdir(CUR_FDIR)


### utils
def os_system_sure(command):
print(f"执行命令:{command}")
result = os.system(command)
if result != 0:
print(f"命令执行失败:{command}")
exit(1)
print(f"命令执行成功:{command}")


CRAC_INSTALL_DIR = "/usr/jdk_crac"


bins=[
"java",
"javac",
"jcmd"
]
# swicth back to openjdk
for bin in bins:
os_system_sure(f"update-alternatives --install /usr/bin/{bin} {bin} {CRAC_INSTALL_DIR}/bin/{bin} 100")
os_system_sure(f"update-alternatives --set {bin} {CRAC_INSTALL_DIR}/bin/{bin}")




# Check and update JAVA_HOME in /etc/environment
with open("/root/.bashrc", "r") as env_file:
lines = env_file.readlines()

java_home_set = False
for line in lines:
if line.startswith("export JAVA_HOME="):
line=f"export JAVA_HOME={CRAC_INSTALL_DIR}\n"
java_home_set = True
if not java_home_set:
lines.append(f"export JAVA_HOME={CRAC_INSTALL_DIR}\n")
print("env lines: ",lines)

with open("/root/.bashrc", "w") as env_file:
env_file.writelines(lines)
3 changes: 3 additions & 0 deletions src/master/m_master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ use crate::{
util::JoinHandleWrapper,
};

#[allow(dead_code)]
trait NodeWeighteFetcher: Send + Sync + 'static {
// NOTE: get weight return node weight
// larger is better
fn get_node_weight(&self, id: NodeID) -> f64;
}

#[allow(dead_code)]
struct StrawNodeSelector {
weight_fetcher: Box<dyn NodeWeighteFetcher>,
}
Expand Down Expand Up @@ -54,6 +56,7 @@ pub trait NodeSelector: Send + Sync + 'static {
fn select_node(&self, all_node_cnt: usize, fn_name: &str) -> NodeID;
}

#[allow(dead_code)]
struct HashNodeSelector;

impl NodeSelector for HashNodeSelector {
Expand Down

0 comments on commit b23aaab

Please sign in to comment.