page static utility

utility of grasping web content and rsyncings

License

License

GroupId

GroupId

com.github.bingoohuang
ArtifactId

ArtifactId

pagestatic
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

page static utility
utility of grasping web content and rsyncings
Project URL

Project URL

http://github.com/bingoohuang/pagestatic
Source Code Management

Source Code Management

http://github.com/bingoohuang/pagestatic

Download pagestatic

How to add to project

<!-- 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"]

Dependencies

compile (6)

Group / Artifact Type Version
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

Project Modules

There are no modules declared in this project.

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
[email protected] $ssh-keygen
  1. copy the key to the remotes
[email protected] $ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
  1. check whether it is ssh ok without password
ssh [email protected]

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();

Versions

Version
0.0.1