Monday, September 19, 2011

How to publish artifacts to ivy local repository and use it in another project

Build artifacts that are required by another project

ivy.xml: Attributes organisation, module and revision of element ivy-module/info.

1) Add a new resolver to ivy by adding following snippet to ivysettings.xml:

<filesystem name="gerald-local-ivy" m2compatible="false" force="false" local="true">
    <artifact pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/>
</filesystem>
This will create a directory local under <user.home>/.ivy2/.

2) Add following snippet to your build.xml:

<target name="publish" depends="jar" description="Publish">
    <!-- following property defines the version to publish -->
<property name="ivy.deliver.revision" value="${version}"/> <ivy:publish resolver="gerald-local-ivy" forcedeliver="true" settingsRef="${ant.project.name}.ivy.settings" overwrite="true"> <artifacts pattern="${build.dir}/[artifact]-[revision](-[classifier]).[ext]" /> </ivy:publish> </target>

The resolver attribute of ivy:publish must match name attribute specified in step 1). Change pattern attribute for artifacts element to match where you put the artifact.

3) Use command ant publish to publish your jar.

Build main project that depends on the artifacts built above.

1) Add the same resolver to ivy by adding following snippet to ivysettings.xml:

<filesystem name="gerald-local-ivy" m2compatible="false" force="false" local="true">
    <artifact pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/>
</filesystem>

2) Add it to your effective resolver chain.

3) Add dependency declaration to ivy.xml

<dependency org="<organization>" name="<module>" 
            rev="<version>" conf="<common->master>">
The attributes org, name, rev must match the values specified when you built the dependency jar.

4) Manually remove the artifacts that exist in local cache (<user.home>/.ivy2/cache).

5) Build your project

Resources

http://ant.apache.org/ivy/history/2.2.0/use/publish.html
http://ant.apache.org/ivy/history/latest-milestone/resolver/chain.html
http://stackoverflow.com/questions/353336/how-does-ivypublish-work
http://mail-archives.apache.org/mod_mbox/ant-ivy-user/201002.mbox/%3C27714488.post@talk.nabble.com%3E

Sunday, September 18, 2011

Configure ivy to use local Maven repository

This post shows how to configure ivy to use specific local Maven repository.

1) Add following config as a child element of tag "resolvers" in you ivy settings file:

    <filesystem name="local-maven-2" m2compatible="true" force="false" local="true">
       <artifact pattern="${gerald.repo.dir}/[organisation]/[module]/[revision]/[module]-[revision].[ext]"/>
       <ivy pattern="${gerald.repo.dir}/[organisation]/[module]/[revision]/[module]-[revision].pom"/>
    </filesystem>
2) Then add it to your chain resolver config. Example: 
    <chain name="internal" dual="true">
      <resolver ref="local-maven-2"/>
      <resolver ref="apache-snapshot"/> 
      <resolver ref="maven2"/>
    </chain>

If you have multiple resolver chain, make sure that the correct one, which is effective for you build, is changed.

3) After ivy caches the artifacts in its own local repo (the first time the dependency is resolved), it will not pick changes you made to the artifacts in the original Maven repository.  In other words, if you use "mvn clean install" to re-publish the artifact, the new version will NOT propagate to ivy.
You can change the default behavior by tweaking parameters:
    checkmodified, changingPatternchangingMatcher, alwaysCheckExactRevision
Read this article for details: http://ant.apache.org/ivy/history/trunk/settings/resolvers.html
One example:

    <chain name="default" dual="true" 
	     checkmodified="true" changingPattern=".*SNAPSHOT">
     ......
    </chain>

Resources:

http://mail-archives.apache.org/mod_mbox/ant-ivy-user/200807.mbox/raw/%3C94bda3fa0807202250y446a818eodb527dba96c8ac93@mail.gmail.com%3E/

Tuesday, September 13, 2011

Vdbench notes

Two types of supported testings.  Following table shows the configuration groups for these testings.

Storage device testing File system testing
General - optional General - optional
Host Definition(HD) - optional Host Definition (HD) - optional
Storage Definition(SD) File System Definition (FSD)
Workload Definition(WD) File System Workload Definition(FSWD)
Run Definition (RD) Run Definition (RD)

Different configuration groups may be specified in one single file or multiple files (use multiple -f options to specify all of them).

Comments: a line starting with '/', '#', or '*' is a comment.
Continuation: end a line with a comma plus a whitespace.

Output file
-o dirname+   # if dirname has existed, use dirname001.
-o dirname.tod    # the directory name will be dirname.yymmdd.hhmmss

General parameters

Vdbench_global_param

Host definition

Vdbench_host_def_param

Storage definition

Vdbench_storage_def_param

Workload definition

Vdbench_workload_def

Run definition

Vdbench_run_def_param

File System Definition

Vdbench_filesystem_def_param

File System Workload Definition

Vdbench_filesystem_workload_def_param

Run definition for file system testing

Vdbench_run_def_fs_param

Resources:
Official doc: http://downloads.sourceforge.net/project/vdbench/vdbench502.pdf?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fvdbench%2Ffiles%2F&ts=1315925901&use_mirror=superb-sea2

Friday, September 09, 2011

R notes

Construct a list of lists

a = c(1,2,3)
b = c(4,5,6)
c = list(a, b)
d = list(c, list(a))    # different from list(c, a)
e = list(d, name="gerald")

Append to a list:

mylist[[length(mylist) + 1]] = obj

Append to a vector:

append(vec, val)

 

Type information

typeof(var),  class(var)

Resources

Monday, September 05, 2011

How to get network information in Linux

Following files/dirs can be directly read:

/proc/net/dev
/sys/class/net/<if_name>/
/sys/class/net/<if_name>/statistics

Tool netstat is your friend to get network-related information:

netstat -I  # display interface info
netstat -s  # display statistics info
netstat -r  # display routing info
netstat -tlnp  # display TCP listening info

Other tools: sar, ifconfig, iftop