- 浏览: 2539171 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Monitor Directory and File(I)Notify
1. Install inotify on Ubuntu
>sudo apt-get install Inotify-tools
2. Install inotify on redhat
http://inotify-tools.sourceforge.net/
>wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
>tar zxvf inotify-tools-3.14.tar.gz
>cd inotify-tools-3.14
>./configure --prefix=/opt/tools/inotify
>make
>make install
3. we need copy some dll or so to our directory.
find the directory of java.library.path
Put these codes in Java Application and note the directory
System.getProperty("java.library.path")
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386/server:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/../lib/i386:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386/client:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386:
/usr/lib/xulrunner-addons:
/usr/lib/xulrunner-addons:
/usr/lib/xulrunner-addons:
/usr/java/packages/lib/i386:
/lib:
/usr/lib
>sudo cp libjnotify.so /usr/lib/
or we can solve this in another way, at the starting of the java application
java -Djava.library.path=some/folder/path/contain/dll
4. Some test classes
The main test class CategoryNotify.java:
package com.xxxxx.importdata.jnotify;
import net.contentobjects.jnotify.JNotify;
import net.contentobjects.jnotify.JNotifyException;
public class CategoryNotify {
public static void main(String[] args) {
// path to watch
String path = "/home/luohua/life/work/xxxxx/xxxxx-gen/records/";
// System.out.println(System.getProperty("java.library.path"));
// watch mask, specify events you care about,
// or JNotify.FILE_ANY for all events.
// int mask = JNotify.FILE_CREATED | JNotify.FILE_DELETED
// | JNotify.FILE_MODIFIED | JNotify.FILE_RENAMED;
int mask = JNotify.FILE_MODIFIED;
// watch subtree?
boolean watchSubtree = true;
// add actual watch
int watchID = 0;
try {
watchID = JNotify.addWatch(path, mask, watchSubtree,
new CategoryListener());
} catch (JNotifyException e) {
e.printStackTrace();
}
// sleep a little, the application will exit if you
// don't (watching is asynchronous), depending on your
// application, this may not be required
try {
Thread.sleep(1000000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// to remove watch the watch
boolean res = false;
try {
res = JNotify.removeWatch(watchID);
} catch (JNotifyException e) {
e.printStackTrace();
}
if (!res) {
// invalid watch ID specified.
}
}
}
The listener class CategoryListener.java:
package com.xxxxxx.importdata.jnotify;
import net.contentobjects.jnotify.JNotifyListener;
public class CategoryListener implements JNotifyListener {
public void fileRenamed(int wd, String rootPath, String oldName,
String newName) {
print(wd + "-renamed " + rootPath + " : " + oldName + " -> " + newName);
}
public void fileModified(int wd, String rootPath, String name) {
print(wd + "-modified " + rootPath + " : " + name);
}
public void fileDeleted(int wd, String rootPath, String name) {
print(wd + "-deleted " + rootPath + " : " + name);
}
public void fileCreated(int wd, String rootPath, String name) {
print(wd + "-created " + rootPath + " : " + name);
}
void print(String msg) {
System.err.println(msg);
}
}
And the outputs are as follow:
0-modified records : 2011_06_22/15/15_57_52_5438.txt
0-modified records : 2011_06_22/15/15_57_52_5438.txt/
0-modified records : 2011_06_22/15/15_57_53_2702.txt
0-modified records : 2011_06_22/15/15_57_53_2702.txt/
references:
http://www.iteye.com/topic/1096698
http://hi.baidu.com/lylianyu/blog/item/a26f5dec7e1b16c62e2e2110.html
http://www.blogjava.net/quaff/archive/2006/03/02/33229.html
http://www.java3z.com/cwbwebhome/article/article5/5843.html
http://commons.apache.org/io/apidocs/org/apache/commons/io/monitor/FileAlterationObserver.html
inotify
http://hi.baidu.com/johntech/blog/item/e4a31a3db1ee1ce755e723f4.html
http://www.ibm.com/developerworks/cn/linux/l-inotifynew/
jnotify
http://jnotify.sourceforge.net/
http://whitesock.iteye.com/blog/431147
http://varsoft.iteye.com/blog/873622
1. Install inotify on Ubuntu
>sudo apt-get install Inotify-tools
2. Install inotify on redhat
http://inotify-tools.sourceforge.net/
>wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
>tar zxvf inotify-tools-3.14.tar.gz
>cd inotify-tools-3.14
>./configure --prefix=/opt/tools/inotify
>make
>make install
3. we need copy some dll or so to our directory.
find the directory of java.library.path
Put these codes in Java Application and note the directory
System.getProperty("java.library.path")
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386/server:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/../lib/i386:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386/client:
/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386:
/usr/lib/xulrunner-addons:
/usr/lib/xulrunner-addons:
/usr/lib/xulrunner-addons:
/usr/java/packages/lib/i386:
/lib:
/usr/lib
>sudo cp libjnotify.so /usr/lib/
or we can solve this in another way, at the starting of the java application
java -Djava.library.path=some/folder/path/contain/dll
4. Some test classes
The main test class CategoryNotify.java:
package com.xxxxx.importdata.jnotify;
import net.contentobjects.jnotify.JNotify;
import net.contentobjects.jnotify.JNotifyException;
public class CategoryNotify {
public static void main(String[] args) {
// path to watch
String path = "/home/luohua/life/work/xxxxx/xxxxx-gen/records/";
// System.out.println(System.getProperty("java.library.path"));
// watch mask, specify events you care about,
// or JNotify.FILE_ANY for all events.
// int mask = JNotify.FILE_CREATED | JNotify.FILE_DELETED
// | JNotify.FILE_MODIFIED | JNotify.FILE_RENAMED;
int mask = JNotify.FILE_MODIFIED;
// watch subtree?
boolean watchSubtree = true;
// add actual watch
int watchID = 0;
try {
watchID = JNotify.addWatch(path, mask, watchSubtree,
new CategoryListener());
} catch (JNotifyException e) {
e.printStackTrace();
}
// sleep a little, the application will exit if you
// don't (watching is asynchronous), depending on your
// application, this may not be required
try {
Thread.sleep(1000000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// to remove watch the watch
boolean res = false;
try {
res = JNotify.removeWatch(watchID);
} catch (JNotifyException e) {
e.printStackTrace();
}
if (!res) {
// invalid watch ID specified.
}
}
}
The listener class CategoryListener.java:
package com.xxxxxx.importdata.jnotify;
import net.contentobjects.jnotify.JNotifyListener;
public class CategoryListener implements JNotifyListener {
public void fileRenamed(int wd, String rootPath, String oldName,
String newName) {
print(wd + "-renamed " + rootPath + " : " + oldName + " -> " + newName);
}
public void fileModified(int wd, String rootPath, String name) {
print(wd + "-modified " + rootPath + " : " + name);
}
public void fileDeleted(int wd, String rootPath, String name) {
print(wd + "-deleted " + rootPath + " : " + name);
}
public void fileCreated(int wd, String rootPath, String name) {
print(wd + "-created " + rootPath + " : " + name);
}
void print(String msg) {
System.err.println(msg);
}
}
And the outputs are as follow:
0-modified records : 2011_06_22/15/15_57_52_5438.txt
0-modified records : 2011_06_22/15/15_57_52_5438.txt/
0-modified records : 2011_06_22/15/15_57_53_2702.txt
0-modified records : 2011_06_22/15/15_57_53_2702.txt/
references:
http://www.iteye.com/topic/1096698
http://hi.baidu.com/lylianyu/blog/item/a26f5dec7e1b16c62e2e2110.html
http://www.blogjava.net/quaff/archive/2006/03/02/33229.html
http://www.java3z.com/cwbwebhome/article/article5/5843.html
http://commons.apache.org/io/apidocs/org/apache/commons/io/monitor/FileAlterationObserver.html
inotify
http://hi.baidu.com/johntech/blog/item/e4a31a3db1ee1ce755e723f4.html
http://www.ibm.com/developerworks/cn/linux/l-inotifynew/
jnotify
http://jnotify.sourceforge.net/
http://whitesock.iteye.com/blog/431147
http://varsoft.iteye.com/blog/873622
发表评论
-
Stop Update Here
2020-04-28 09:00 310I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 465NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 361Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 363Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 328Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 419Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 364Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 444VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 376Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 463NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 413Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 330Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 242GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 443GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 320GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 306Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 284Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 302Serverless with NodeJS and Tenc ...
相关推荐
《基于JDK7的FileMonitor:精简版文件监控服务详解》 在Java开发中,对文件系统的实时监控是一项常用且重要的任务。JDK7引入了`WatchService`接口,为开发者提供了一种监听文件系统变化的能力。然而,`WatchService...
标题 "FileNotify.rar_CE 2005_Win CE SDK_filenoti_notify_win CE 5" 暗示了这是一个关于Windows CE操作系统中文件通知功能的开发资源包,主要用于Windows CE 5.0版本。这个资源可能包含了在Windows CE平台上实现...
然后,我们调用ReadDirectoryChangesW函数,设置要监控的事件类型(如FILE_NOTIFY_CHANGE_FILE_NAME、FILE_NOTIFY_CHANGE_DIR_NAME等),并提供一个FILE_NOTIFY_INFORMATION结构体数组来接收变化信息: ```cpp ...
这个压缩包文件`WM_NOTIFY.zip_WM_NOTI_WM_NOTIFY`包含了关于`WM_NOTIFY`消息的深入分析和理解,以及可能的资源链接。我们将详细探讨`WM_NOTIFY`消息的原理、使用场景及其在实际应用中的价值。 `WM_NOTIFY`消息是...
Notify_1.4_truncate.docx Notify_1.7_client_design.doc Notify_1.7_client_develop_guide.docx ... ... Notify1.7_server_design.docx Notify1.7UserGuide.pptx Notify1.8_SEDA.docx Notify2010plan.pptx Notify...
标题中的"file_change_notify.rar_Change"暗示了这个压缩包包含了一个关于文件变更通知的程序或库。描述中提到的“在文件改变时得到通知,更具人性化风格”表明这是一个能够实时监控并提醒用户文件变化的工具,可能...
在Java中,`wait()` 和 `notify()` 方法是实现线程间通信和协作的重要工具,它们属于 `java.lang.Object` 类,这意味着所有类都默认继承了这两个方法。本文将详细探讨如何使用 `wait()` 和 `notify()` 来控制子线程...
HANDLE dirHandle = CreateFileW(L"C:\\path\\to\\directory", FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);...
### MFC全面解读WM_NOTIFY 在MFC(Microsoft Foundation Classes)框架中,`WM_NOTIFY`消息扮演着极其关键的角色,特别是在处理控件间通信时。本文将深入解析`WM_NOTIFY`消息的机制、应用场景以及其在MFC中的实现...
FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE, &dwBytesReturned, &overlapped, NULL)) { _tprintf(_T("Failed to read directory ...
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SECURITY); // 监视的事件类型...
notify.js 好用的提示工具
wait和notify讲解
这些方法主要用于解决线程等待和唤醒的问题,是基于Java Monitor(监视器)模型的。 首先,我们来看一下`synchronized`关键字。在Java中,`synchronized`用于创建临界区,确保同一时间只有一个线程能够执行特定代码...
hChange = FindFirstChangeNotification(path, False, FILE_NOTIFY_CHANGE_FILE_NAME Or FILE_NOTIFY_CHANGE_DIR_NAME) If hChange <> -1 Then Do If Not FindNextChangeNotification(hChange) Then ' 处理文件...
$notify = new \Jenner\LogMonitor\Notification\EchoNotification(); $process = new \Jenner\LogMonitor\MonitorTask($reader, $filter, $notify); $process->run(); $process->wait(); 标签:log...
"自动使能 notify" 是一种功能,它涉及自动化流程和通知机制。在20170706这个日期点,可能是一个系统或软件更新,或者一个特定项目的一部分,其中从机被配置为能够自动启用通知功能。这可能是为了提高效率,减少人工...
在Laravel框架中,`laravel-notify`是一个非常实用的扩展包,它为开发者提供了方便的通知接口,以便在Laravel4项目中实现各种通知功能。这个包的主要目的是简化通知的创建、管理和展示,使开发者可以更加专注于业务...
bootstrap-notify.js bootstrap的提示框插件
【IBM Thread And Monitor Dump Analyser】是一款专门用于分析Java应用程序线程状态的工具,它能够帮助开发者深入理解程序在特定时刻的运行情况,特别是在遇到性能问题或者系统挂起时,提供宝贵的诊断信息。...