Skip to content

Commit

Permalink
rename config files for simple upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
adyliu committed Dec 25, 2013
1 parent 6c80939 commit 254c156
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ __pycache__
/.idea
*.iml
pom-*.xml
dist
28 changes: 24 additions & 4 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
Simple Install Guide
====
======

The package can be builded on any Java enviroment.

Require
====
======

* JDK 1.6+ (maybe works on JDK 1.5+ after changing the pom)
* Maven 2.2+ (3.0+ better)

Build
====
======

Build the source with maven:

mvn clean package assembly:single -Dmaven.test.skip=true

Expand All @@ -20,5 +22,23 @@ We recomment you to run the unit test.

Copy and unpack the package 'target/jafka-1.x.x-all.tar.gz' while 1.x.x is the version.

Install & Upgrade
======

copy 'server.properties' and 'log4j.properties' from sample or previous installation:

cp conf/server.properties.sample conf/server.properties
cp conf/log4j.properties.sample conf/log4j.properties


Run
======

Start the service with wrapper script:

chmod +x bin/run.sh
bin/run.sh console

----
Full install guide: https://github.com/adyliu/jafka/wiki/install

Full install guide: https://github.com/adyliu/jafka/wiki/install
5 changes: 2 additions & 3 deletions bin/jafka.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ wrapper.java.command=java
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
wrapper.java.classpath.1=%JAFKA_HOME%/lib/*.jar
wrapper.java.classpath.2=%JAFKA_HOME%/bin/optional/*.jar
wrapper.java.classpath.3=%JAFKA_HOME%/bin
#wrapper.java.classpath.4=%JAFKA_HOME%/lib/optional/*.jar
wrapper.java.classpath.3=%JAFKA_HOME%/conf

wrapper.java.library.path.1=%JAFKA_HOME%/bin/optional

Expand All @@ -34,7 +33,7 @@ wrapper.app.parameter.2=%JAFKA_HOME%/conf/server.properties
wrapper.console.format=M
wrapper.console.loglevel=INFO
wrapper.logfile=%JAFKA_HOME%/logs/wrapper.log
wrapper.logfile.format=ZM
wrapper.logfile.format=M
wrapper.logfile.loglevel=INFO
wrapper.logfile.maxsize=1024m
wrapper.logfile.maxfiles=7
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion conf/server.properties → conf/server.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ port=9092

# The directory under which to store log files.
# The directory must be empty or only contains jafka files.
log.dir=./data
log.dir=/tmp/jafka-data

# The number of logical partitions per topic per server. More partitions allow greater parallelism
# for consumption, but also mean more files.
Expand Down
14 changes: 1 addition & 13 deletions src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
<file>
<source>VERSION</source>
<outputDirectory>/</outputDirectory>
</file>
<file>
<source>conf/log4j.properties.in</source>
<outputDirectory>/bin</outputDirectory>
<destName>log4j.properties</destName>
</file>
</file>
</files>
<fileSets>
<fileSet>
Expand All @@ -37,13 +32,6 @@
<exclude>*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>src/main/assembly</directory>
<outputDirectory>/data</outputDirectory>
<excludes>
<exclude>*</exclude>
</excludes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/sohu/jafka/Jafka.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
import com.sohu.jafka.server.ServerConfig;
import com.sohu.jafka.server.ServerStartable;
import com.sohu.jafka.utils.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Closeable;
import java.io.File;
import java.util.Properties;

/**
Expand All @@ -40,9 +43,15 @@ public class Jafka implements Closeable {
private ServerStartable serverStartable;
// server listening port
private int port = -1;
private final Logger logger = LoggerFactory.getLogger(Jafka.class);

public void start(String mainFile, String consumerFile, String producerFile) {
start(Utils.loadProps(mainFile),//
public void start(String mainFileName, String consumerFile, String producerFile) {
File mainFile = Utils.getCanonicalFile(new File(mainFileName));
if (!mainFile.isFile() || !mainFile.exists()) {
System.err.println(String.format("ERROR: Main config file not exist => '%s', copy one from 'conf/server.properties.sample' first.", mainFile.getAbsolutePath()));
System.exit(2);
}
start(Utils.loadProps(mainFileName),//
consumerFile == null ? null : Utils.loadProps(consumerFile),//
producerFile == null ? null : Utils.loadProps(producerFile));
}
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/sohu/jafka/log/DailyRollingStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand All @@ -17,15 +17,15 @@

package com.sohu.jafka.log;

import com.sohu.jafka.utils.Utils;

import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

import com.sohu.jafka.utils.Utils;

/**
* Rolling file every day
*
Expand Down Expand Up @@ -90,19 +90,19 @@ public void run() {
while (running) {
Calendar today = today();
today.add(Calendar.DAY_OF_MONTH, 1);
lock.lock();
try {
lock.lock();
try {
waitCondition.awaitUntil(new Date(today.getTimeInMillis()));
if (System.currentTimeMillis() - lastRollingTime >= ONE_DAY) {
needRolling.compareAndSet(false, true);
}
} finally {
lock.unlock();
waitCondition.awaitUntil(new Date(today.getTimeInMillis()));
if (System.currentTimeMillis() - lastRollingTime >= ONE_DAY) {
needRolling.compareAndSet(false, true);
}
} catch (InterruptedException e) {
running = false;
break;
} finally {
lock.unlock();
}

}
}

Expand Down

0 comments on commit 254c156

Please sign in to comment.