Category Archives: Web

De-Googling myself! (Step 2)

After kicking Gmail out, there are still some problems with mailing transfer. I managed to get a full backup using this old but quite efficient tool: Gmail Backup. I think I’ll be using Thunderbird for desktop use.

 

2016-09-15_16-13-09

Next big thing to deal with, is moving my GDrive data somewhere else, outside my computer and it must not be DropBox. I’m not sure yet it is the best one, but I like the way Kim Dotcom deals with his problems. So, I decided to stick to megaupload v2: Mega.

Cloudwards suggests sync.com as the best alternative to DropBox even if Mega offers 50GB  (vs 5GB to sync.com) of forver free storage. This is what I need for the moment. Moreover, Mega has a valuable tool called MEGAsync. So, all I had to do is download my drive to a single directory using the desktop Google drive app, and then point it a s a source of Sync to MEGASync… then I just kept my computer connected for one night :).

De-Googling myself! (Step 1)

Many of us will never realize how much we are Google dependent until we reach the maximum free storage capacity.

2016-09-15_10-59-05

But, what if google decides to remove the free offer? what can prevent them from doing it? Whatsapp tried but let down after a while … Google is not Whatsapp. Did ever think how much google knows about you?

So I decided to start degoogling my self. There are a lot of alternatives, I have just to be more patient/tolerant with open source ones and choose carefully. Uninstalled the greedy  Google Chrome, downloaded all my files from the Google Drive and looking for a new solution for mailing and remote storage.

Many “Alternatives To” website suggest using “mail.com”. Seems clean and quite interresting as a domain name. But, when I receive this kind of messages on registration, I’m not sure I can go further.

2016-09-15_10-56-13

Then, I came across this beautiful “TutaNota”.

2016-09-15_11-10-38

A replacement for Google Services. This is what I’m looking for.

And here where you can join now : sba@keemail.me

SMS continuous service with Smslib

In Order to create and SMS service, to send sms periodically, you can use Quartz crons mixed with Smslib on a Spring Framework boil.

To set up a quartz cron, please refer this post. Next, we’ll need three Sql tables:

– Active Sms
– Archive Sms
– Smpp Gateway Configuration

Prerequiste library can be found here

Provided Senario:

Scenario

Download links for the latest offline Flash Player Installer

Latest Update (05 April 2016) – Flash Player 21

Tired of searching, here the direct download links of the offline Flash Player Installer :

Found after some search here:

https://helpx.adobe.com/flash-player/kb/installation-problems-flash-player-windows.html#main-pars_header

Load balancing with Apache HTTP

Balanced on the same server

 

workers.properties

worker.list=router,status
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker1.local_worker=1
worker.worker1.ping_timeout=1000
worker.worker1.socket_timeout=10
worker.worker1.ping_mode=A
#sticky session is not interresting here, just for explanation
#sticky session = stick to the server that gave you the first session-id
worker.worker1.sticky_session=true
#this property will make your load balancer woprking in active passive mode
#All requests would be mapped to worker1, but
#on worker1 (server1:8009) failure, all requests will be redirected to worker2
worker.worker1.redirect=worker2

worker.worker2.port=8090
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.worker2.activation=disabled
worker.worker2.ping_timeout=1000
worker.worker2.socket_timeout=10
worker.worker2.ping_mode=A
worker.worker2.local_worker=0
worker.worker2.sticky_session=true

worker.router.type=lb
worker.router.balanced_workers=worker1,worker2
worker.router.sticky_session=true
worker.status.type=status

httpd.conf

...
LoadModule jk_module modules/mod_jk.so
...
#go to the end of the file and add the
JkWorkersFile /etc/httpd/conf/workers.properties
JkShmFile /etc/httpd/logs/mod_jk.shm
JkLogFile /etc/httpd/logs/mod_jk.log
JkLogLevel debug
# Configure monitoring the LB using jkstatus
JkMount /jkstatus/* status
# Configure your applications (may be using context root)
JkMount /myRootContext* router

2014 in review

The WordPress.com stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

A New York City subway train holds 1,200 people. This blog was viewed about 3,800 times in 2014. If it were a NYC subway train, it would take about 3 trips to carry that many people.

Click here to see the complete report.

Just another mirror for HBase

While testing the Hadoop database, HBase, I noticed that dedicated mirrors were very slow. Here’s another link using 4shared.

hbase-0.99.2-bin.tar.gz

 

By the way, if you see this error while trying to start HBase (./start-hbase.sh):

$ ./start-hbase.sh
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/hadoop/hbase/util/HBaseConfTool : Unsupported major.minor version 51.0

Be sure that you’re running the minimum required JDK (1.7) and that the HBASE_HOME is set. I found this line in hbase-env.sh:

# The java implementation to use.  Java 1.7+ required.
# export JAVA_HOME=/usr/java/jdk1.6.0/

Simple JTAPI Applet – CISCO Implementation

JTAPI is a Java library intended to ensure communication between a Java client and a CTI server. There are many implementations of JTAPI, proprietary(AVAYA, CISCO,…) and open source(GJTAPI, XTAPI). I’ve been working on an Applet to replace the CISCO IP Communicator. This applet uses the CISCO JTAPI implementation to listen to incoming calls, emit consultation calls and execute a call transfer. A consultation call is a call to a target number (B) started by an agent while receiving another call from source (A). The active call from A is switched to “waiting mode” (listening to some music on the wait tone). The agent has the possibility to join source A to target B without listening to their conversation (not a conference).

To achieve this task, I’ve been reading the JTAPI developer guide. The test platform preparation is not discussed in this post. Two common problems to solve to make this applet work correctly: How to make the applet access to local resources(mainly client logging)? How to implement these functions with such a restricted community?

To enable the applet interaction with client local resources, I implemented a test one. the applet looks like :

<div>
<applet id="sph" code="com.interop.cisco.MiniSoftphone.class"
archive="miniphone.jar,jtapi.jar,log4j.jar" />

</div>

The miniphone.jar holds my implementation of the applet (MiniSoftphone.java), “jtapi.jar” is the cisco JTAPI implementation and “log4j.jar” is the default logging library for CISCO JTAPI. Note that this applet also interacts with an SWF (the main application) via some JS code. To avoid paths problems, I moved those libraries to the root context of my application under the server.

To execute the applet in IE for example, you have first of all to sign you jar with a valid certificate (using jarsigner tool from the default JDK installation bin). You will have to update your browser plugin  to the latest java release. Next, you have to trust your host in the java configuration panel.

Trust Server

To manage logging params in JTAPI, use the given CISCO tool(Cisco Unified Communications Manager JTAPI Preferences). You need also to place the jtapi.ini side by side with jtapi.jar. If this file is not generated during installation process, use the following command:

java CiscoJtapiVersion -parms

Then you can manage logging properties. It is useful to enable all traces for tests for easier troubleshooting.

2014-12-04_1514Logging management

 

 

 

 

 

 

 

 

 

 


 

In the Log Destination tab, I used “c:\TEMP\” as logging path. This will create a rolling file where every action of the JTAPI is logged. You can also use the client java console as an output. An interesting tip here, is how to print an exception stack trace into a given text box for example (inConsole is an AWT TextField in this snippet).

  StringWriter sw = new StringWriter();
  PrintWriter ps = new PrintWriter(sw);
  e.printStackTrace(ps);
  inConsole.append(sw.toString()+"\r\n");

One more thing to add in the user home to enable the applet write in a local directory: Create a file called “.java.policy” in the user home dir, and assign wanted rights to your source server:

grant codeBase "http://localhost:8080/ctiapp/*" {
  permission java.io.FilePermission "C:\\TEMP\\*", "read";
};
grant codeBase "http://localhost:8080/ctiapp/*" {
  permission java.io.FilePermission "C:\\TEMP\\*", "write";
};

Now, as soon as I went to my applet web page,  IE asked me to accept this “hazardous” applet:

Applet warning signed jar

So, I’m done with the first problem. Let’s now focus on the JTAPI implementation.

First of all, we need a valid CUCM server with valid credentials. We have to implement the ProviderObserver interface with its providerChangedEvent (aProviderObserverImpl).


public void providerChangedEvent ( ProvEv [] eventList ) {
if ( eventList != null ) {
for ( int i = 0; i < eventList.length; i++ )
{
if ( eventList[i] instanceof ProvInServiceEv )

{
conditionInService.set ();
}
}
}
}

Then, we try to connect the applet to the CUCM (providerName=CUCM IP; Login=cucem username; passwd=cucm password):

 Provider provider;
 JtapiPeer peer = JtapiPeerFactory.getJtapiPeer ( null );
 String providerString = providerName + ";login=" + login + ";passwd=" + passwd;
 logger.info( "INFCTI101 Trying to reach provider[Connection String :" + providerString + "]" );
 provider = peer.getProvider ( providerString );
 provider.addObserver ( aProviderObserverImpl);
 conditionInService.waitTrue ();

Next, we need to implement the CallObserver interface to listen to call events.

protected final void metaEvent ( CallEv [] eventList ) {
 //logger.info("INFCTI100 Received a CallEv array event - Length = "+eventList.length);
 for ( int i = 0; i < eventList.length; i++ ) {
 TerminalConnection tc = null;
 try {
 CallEv curEv = eventList[i];
 // logger.info("INFCTI101 Processing event item : "+i);
 if ( curEv instanceof CallCtlTermConnRingingEv ) {
 // logger.info("INFCTI102 Event type is : CallCtlTermConnRingingEv.");
 tc = ((CallCtlTermConnRingingEv)curEv).getTerminalConnection ();
 //logger.info("INFCTI103 CTI connection is : "+(tc!=null?tc.getState():"null"));
 tc.answer ();
 //logger.info("INFCTI104 Agent answered the call....");
 }else if (curEv instanceof CallControlCall) {
 CallControlCall ccc = (CallControlCall)curEv.getCall();
 String callerName = ccc.getCallingAddress().getName();
 System.out.println("Received a call from "+callerName);
 //logger.info("INFCTI105 Event type is : CallControlCall. Caller =["+callerName+"]");
 }
 }
 catch ( Exception e ) {
//redirect the e.printstacktrace to a textField for example
 }
 }
 }

//still a draft…

A very short introduction to MongoDB

Mong

 

Originally called humongous (big, enormous), the MongoDB project is carried by Eliot & Dwight since 2007. This is one of the best NoSql concepts implementation. For SQL fanatics, there is a small comparison between the SQL and the MongoDB NoSQL implementation.

NoSQL does not stand for “NO TO SQL” or “NON SQL”. It stands for “Not Only SQL”.

Recently I was testing it and I decided to pin this post for me and my team as a reminder.

MongoDB does not offer any official GUI. They delegated the mission to the community, and I think it was the right choice as there are now many GUI tools developed by the growing MongoDB community.

You can download the latest version from the mongodb.org. Install it as an administrator if you are on Windows.

The default datastore for MongoDB is c:\data\db. Alternatively, you can specify the datastore when starting the DB engine (–dpath=”yourpath”).

To start the MongoDB server, run “mongod” on CMD. By default, 27017. You can check if the server was started by taping this address in the browser http://localhost:27017/. You will get this message on the page (It looks like you are trying to access MongoDB over HTTP on the native driver port.)
Open another console, and run “mongo.exe”.  First thing you must be aware of, there’s no “CREATE DATABASE” command on MongoDB. Let’s now create a new database called “knw”.  We’ll create a “table” called “projects” inside this database. A table in the MongoDB terminology is called a collection. A collection is a set of “rows” (called documents in this NoSQL variant). We’ll back to collections later in this post.

 >mongo.exe
 MongoDB shell version: 2.6.3
 connecting to: test
//something like mysql use to specify current database
 > use knw 
 switched to db knw
 > show dbs;
 admin (empty)
 local 0.078GB
//there are no custom databases yet
//now, we'll insert a document in the table projects (not yet created)
 > db.projects.insert({name:"DALEEL", 
                  description:"Directories and VAS plateforms for call centers", 
                  start_date:"2008-07-01"})
 WriteResult({ "nInserted" : 1 })
 > show dbs
 admin (empty)
 knw 0.078GB
 local 0.078GB
//You can see that knw database was created

So, the database “knw” and the collection “projects” were created on first document insertion. Note that a collection can contain many documents with different structure.

> db.projects.insert({client:"Currency Museum", 
                      name:"CMM", 
                      description:"Currency Museum management platform"})
WriteResult({ "nInserted" : 1 })

As you can see, column (field) names are not the same (“client” field does not appear in the first document although they are stored in the same collection).

Note also that a field value can be an integer, a string, a date  (etc) or a full document. (like “soldTo” field)

> db.projects.insert({name:"GEDARC", 
                      description:"EDM and ARCHIVES MGMT platform", 
                      soldTO:{ 
                               name:"Client A", 
                               country:"TN", 
                               licence:1, 
                               renew:true
                             }
                     } )
WriteResult({ "nInserted" : 1 })

The select of MongoDB is called “find”. To find our main project “DALEEL”.

> db.projects.find({name:"DALEEL"})
{ "_id" : ObjectId("547d8321a2fdc9b65ab4805a"), "name" : "DALEEL", "description" : "Directories and VAS plateforms for call centers", "start_date" :
"2008-07-01" }

Now, you can start reading about NoSQL and MongoDB. There is something really humongous about MongoDB: The documentation 😉

One more post, I want you all to check before starting any project based on NoSQL spec, Sarah Mei arguing “Why you should never use MongoDB“.

How a NoSQL DB looks like in real world ? :D

How a NoSQL DB looks like in real world ? 😀

Lucene.Net corrupt indexes

lucene.net

 

 

DotLucene is the dotNet version of Java Lucene API. It is still an open source project with a smaller community. There are many classes that needs to be implemented especially those specific to the Java world. Many open source projects are built on top od DotLucene such as SubText, Lucandra.Net (Lucene and Cassandra) and the awesome RavenDB.
I’ve been using it since 2008 and I want to thank everyone that helped revive this project after two years of hibernation.

When playing with the .Net implementation, I faced the ambiguous exception saying “Read Past EOF”.  Contributors always suspected corrupt indexes. It was not my case: I double checked using the CheckIndex.Status class and it does not reveal any problem. I went through the Lucene.Net DLL code, and focused on the method throwing the error(Refill())


private void Refill()

{
long start = bufferStart + bufferPosition;
long end = start + _bufferSize;
if (end > Length())
// don't read past EOF
end = Length();
int newLength = (int) (end - start);

if (newLength <= 0)// The error is thrown here
throw new System.IO.IOException("read past EOF");

if (buffer == null)
{
NewBuffer(new byte[_bufferSize]); // allocate buffer lazily
SeekInternal(bufferStart);
}
ReadInternal(buffer, 0, newLength);
bufferLength = newLength;
bufferStart = start;
bufferPosition = 0;

To check whether your indexes are corrupt or not, you can use the CheckIndex class as below:

Dim cheker As CheckIndex = New CheckIndex(idxdir)
Dim status As CheckIndex.Status = checker.CheckIndex_Renamed_Method()

The status holds many attributes which can ensure the health of your indexes. Mine shows this:
CheckIndex.Status
So the indexes are healthy, no locks is left there (check locks on file also using Lock Hunter), RW rights are set up correctly, so what was happening?

 

Simply, a coding error ^^’


Dim pth As String = Application.StartupPath + INDEX_PATH + "\" + entityName
Dim idxdir As Lucene.Net.Store.Directory = SimpleFSDirectory.Open(New IO.DirectoryInfo(pth))
Dim crawler As IndexSearcher = New IndexSearcher(idxdir, False)

//and later when iterating through the results (i is the counter)

Dim scrd As ScoreDoc = hts.ScoreDocs(i)

//the error occurs here
Dim doc As Document = crawlr.Doc(scrd.Doc)

Two hours and 25 pages to find out the problem…. the crawler is the index searcher that fetches a given entity (entityName), whereas the  crawlr (without “e” before the “r”) is a global index searcher used somewhere else… That’s all.

A good lesson, do a diff for your team’s updates before starting any bug fix!

gym