page static utility

utility of grasping web content and rsyncings

Лицензия

Лицензия

Группа

Группа

com.github.bingoohuang
Идентификатор

Идентификатор

pagestatic
Последняя версия

Последняя версия

0.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

page static utility
utility of grasping web content and rsyncings
Ссылка на сайт

Ссылка на сайт

http://github.com/bingoohuang/pagestatic
Система контроля версий

Система контроля версий

http://github.com/bingoohuang/pagestatic

Скачать pagestatic

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.bingoohuang/pagestatic/ -->
<dependency>
    <groupId>com.github.bingoohuang</groupId>
    <artifactId>pagestatic</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.bingoohuang/pagestatic/
implementation 'com.github.bingoohuang:pagestatic:0.0.1'
// https://jarcasting.com/artifacts/com.github.bingoohuang/pagestatic/
implementation ("com.github.bingoohuang:pagestatic:0.0.1")
'com.github.bingoohuang:pagestatic:jar:0.0.1'
<dependency org="com.github.bingoohuang" name="pagestatic" rev="0.0.1">
  <artifact name="pagestatic" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.bingoohuang', module='pagestatic', version='0.0.1')
)
libraryDependencies += "com.github.bingoohuang" % "pagestatic" % "0.0.1"
[com.github.bingoohuang/pagestatic "0.0.1"]

Зависимости

compile (6)

Идентификатор библиотеки Тип Версия
commons-httpclient : commons-httpclient jar 3.1
org.jooq : joor jar 0.9.3
com.google.guava : guava jar 17.0
org.slf4j : slf4j-api jar 1.7.5
org.apache.commons : commons-lang3 jar 3.1
commons-io : commons-io jar 2.4

Модули Проекта

Данный проект не имеет модулей.

PageStatic

A java utility program to retrieve content of remote web page and rsync to multiple hosts.

  • when given page url links, PageStatic will reuse http connections by HttpClient.
  • the rsync upload will triggered automatically by the content file max num or timeout.
  • rsync will be checked on timeout and exit-value to ensure its success.
  • all remote hosts will required password-less to use rsync (rsync -az localdir user@remotehost:remotedir).
  • because of PageStatic's own concurrency, only one PageStatic instance is enough.

How to make rsync-over-ssh-without-password

  1. generate key on the PageStatic running host
user1@10.142.195.61 $ssh-keygen
  1. copy the key to the remotes
user1@10.142.195.61 $ssh-copy-id -i ~/.ssh/id_rsa.pub user2@10.142.195.62
  1. check whether it is ssh ok without password
ssh user2@10.142.195.62

Create PageStatic with same upload path

PageStatic pageStatic = new PageStaticBuilder()
    .addRsyncRemote("10.142.151.1", "mall")
	.addRsyncRemote("10.142.151.2", "mall")
	.addRsyncRemote("10.142.151.3", "mall")
	.addRsyncRemote("10.142.151.4", "mall")
	.addRsyncDir("/home/mall/pagestatic/pagehtml/", "/app/pagestatic/")
	
	 // optional
	.httpSocketTimeoutSeconds(60) // default 30 seconds
	.triggerUploadWhenMaxFiles(100) // default 100
	.triggerUploadWhenMaxSeconds(60) // default 120
	.deleteLocalDirAfterRsync(true)  // default true
	.maxUrlContentGeneratingThreads(10) // default 1
	.rsyncTimeoutSeconds(60) // default 30 seconds
	.rsyncRetryTimes(3) // default 3
	
	.build();

Create PageStatic with different upload path

PageStatic pageStatic = new PageStaticBuilder(
	.addRsyncRemote("10.142.151.1", "mall")
	.addRsyncRemote("10.142.151.2", "mall")
	.addRsyncRemote("10.142.151.3", "mall")
	.addRsyncRemote("10.142.151.4", "mall")
	.addRsyncDir("/home/mall/pagestatic/pagehtml/", "10.142.151.1:/app/pagestatic1/")
	.addRsyncDir("/home/mall/pagestatic/pagehtml/", "10.142.151.2:/app/pagestatic2/")
	.addRsyncDir("/home/mall/pagestatic/pagehtml/", "10.142.151.3:/app/pagestatic3/")
	.addRsyncDir("/home/mall/pagestatic/pagehtml/", "10.142.151.4:/app/pagestatic4/")

     // optional
    .httpSocketTimeoutSeconds(60) // default 30 seconds
    .triggerUploadWhenMaxFiles(100) // default 100
    .triggerUploadWhenMaxSeconds(60) // default 120
    .deleteLocalDirAfterRsync(true)  // default true
    .maxUrlContentGeneratingThreads(10) // default 1
    .rsyncTimeoutSeconds(60) // default 30 seconds
    .rsyncRetryTimes(3) // default 3

    .build();

Create PageStatic by config file

addRsyncRemote(10.142.151.1, mall)
addRsyncRemote(10.142.151.2, mall)
addRsyncRemote(10.142.151.3, mall)
addRsyncRemote(10.142.151.4, mall)
addRsyncDir(/home/mall/pagestatic/pagehtml/, /app/pagestatic/)
// optional
httpSocketTimeoutSeconds(60) // default 30 seconds
triggerUploadWhenMaxFiles(100) // default 100
triggerUploadWhenMaxSeconds(60) // default 120
deleteLocalDirAfterRsync(true)  // default true
maxUrlContentGeneratingThreads(10) // default 1
rsyncTimeoutSeconds(60) // default 30 seconds
rsyncRetryTimes(3) // default 3

And then build PageStatic from config like:

PageStatic pageStatic 	= new PageStaticBuilder().fromSpec("DEMO").build();

Use PageStatic

pageStatic.startupBatch();

// batch process
for (…) {
 	…
	// use web url, and local responding file name
	pageStatic.urlStaticAndUpload(url, localFile);
	// or given the direct content and upload
	String content = "<html>I am static html</html>";
	pageStatic.directContentUpload(content, localFile);
}

pageStatic.finishBatch();

Версии библиотеки

Версия
0.0.1