| Station | Streaming Address |
|---|---|
| Cool FM 90.1 | http://equinox.shoutca.st:8938/stream |
| iFM 93.9 Manila | http://curiosity.shoutca.st:8098/stream |
| 90.7 Love Radio Manila | https://manilabr.radioca.st/stream |
| Magic 107 | http://curiosity.shoutca.st:8098/stream/1/ |
| Star FM Manila 102.7 FM | http://ample-zeno-06.radiojar.com/g1pmt17nz9duv |
| YES! FM 101.1 Manila | http://37.59.28.208:8500/stream |
| Monster RX 93.1 | http://icecast.eradioportal.com:8000/monsterrx |
| Rakista Radio | http://206.190.138.197:8000/stream/1/ |
Page 27 of 35
Create an implementation of ThreadFactory to create a thread with custom name for ThreadPoolExecutor as follows:
class MyThreadFactory implements ThreadFactory {
private AtomicLong threadCounter;
private MyThreadFactory() {
threadCounter = new AtomicLong();
}
@Override
public Thread newThread(Runnable runnable) {
var thread=new Thread(runnable);
thread.setName(String.join("-","my-thread",
String.valueOf(threadCounter.incrementAndGet())));
return thread;
}
}
The preceding class will generate a thread with the name starting with my-thread. Use the instance of this class in constructing the ThreadPoolExecutor as follows:
var executor = new ThreadPoolExecutor(2, 4, 60L, TimeUnit.SECONDS,
new ArrayBlockingQueue<>(100), new MyThreadFactory(),
new ThreadPoolExecutor.CallerRunsPolicy());
The preceding declaration creates an instance of ThreadPoolExecutor with 2 core threads, 4 maximum threads, 60 seconds keep alive and supports 100 items in the queue. The queue size is defined by the instance of ArrayBlockingQueue class.
Start all the core threads as follows:
executor.prestartAllCoreThreads();
Using a profiling tool we can search for all the threads whose names starts with my-thread like the following screenshot:
Don't forget to call any shutdown/terminate methods when done using the executor.
If the resource and the module are known, we can use the ModuleLayer to access it like the following snippet.
ModuleLayer.boot().findModule(<MODULE_NAME>).ifPresent(___module -> {
try {
var modResource = ___module.getResourceAsStream(<RESOURCE_NAME>);
} catch (IOException e) {
e.printStackTrace();
}
});
Where:
MODULE_NAME -> the name of the module that has the resource.
RESOURCE_NAME -> the resource of interest.
Pre-requisite
- Git is installed locally.
Procedures
- Checkout the non-master branch to be squashed.
- Ensure that the branch is up to date from the master.
- Open a terminal and change the directory to the root of checked out branch.
- Run the following command:
git rebase -i master
- Once a text editor opens and leave the first pick alone and the subsequent picks must be replaced with squash. For example:
Frompick < hash1 > < message1 > pick < hash2 > < message2 > pick < hash3 > < message3 > pick < hash4 > < message4 >
To
pick < hash1 > < message1 > squash < hash2 > < message2 > squash < hash3 > < message3 > squash < hash4 > < message4 >
- Save the update and close the editor.
- Another editor will open to update the message since git is about the combine multiple commits.
- Update the message if necessary.
- Save and close the editor.
- If everything went fine your branch is now squashed.
Reactive stream is gaining traction in the mainstream programming and java has its own implementation via the Flow API. Popular reactive stream implementations are RxJava, Reactor and Akka.
import java.util.concurrent.Flow;
import java.util.concurrent.SubmissionPublisher;
import java.util.stream.IntStream;
public class Main {
/**
* Sample subscriber implementation.
*/
public static class Subscriber implements Flow.Subscriber<Integer> {
/**
* Holds an instance of Flow.Subscription instance so that we can request what we can handle.
*/
private Flow.Subscription subscription;
/**
* Tracks if the publisher was closed.
*/
private boolean isDone;
/**
* Triggered on the initial subscription.
* @param subscription An instance of Flow.Subscription.
*/
@Override
public void onSubscribe(Flow.Subscription subscription) {
System.out.println("Subscribed");
this.subscription = subscription;
this.subscription.request(1);
}
/**
* Do the actual processing.
* @param item The actual item currently being processed.
*/
@Override
public void onNext(Integer item) {
System.out.println("Processing " + item);
this.subscription.request(1);
}
/**
* Holds how to handle error.
* @param throwable An instance of Throwable.
*/
@Override
public void onError(Throwable throwable) {
throwable.printStackTrace();
}
/**
* Called with the publisher was closed or completed.
*/
@Override
public void onComplete() {
System.out.println("Processing done.");
isDone = true;
}
}
public static void main(String[] args) throws InterruptedException {
//The publisher of the data.
SubmissionPublisher<Integer> publisher = new SubmissionPublisher<>();
//The sample subscriber implementation.
Subscriber subscriber = new Subscriber();
//Register a subscriber.
publisher.subscribe(subscriber);
//The sample stream to process.
var intData = IntStream.rangeClosed(1, 10);
//Publish the stream data.
intData.forEach(publisher::submit);
//The publisher is done.
publisher.close();
//Since this is processing is asynchronous wait for everything to be processed.
while(!subscriber.isDone) {
Thread.sleep(10);
}
System.out.println("Done");
}
}
Download older version of java from the following address:
- Open the Services application and look for SQL Server (SQLEXPRESS).
- Stop the SQL Server (SQLExpress) service.
- Right-click the SQL Server (SQLExpress) service and select Properties.
- At the Start parameters field type in -m.
- Click the Start button.
- Close the Services application.
- Open a Command Prompt in elevated mode.
- Execute the following command:
osql -S <LOCAL_PC_NAME>\SQLEXPRESS -E
Note: The <LOCAL_PC_NAME> must be changed appropriately.
- At the prompt generated by the previous command invoke the following commands in sequence:
sp_password NULL,'<NEW_PASSWORD>','sa'
Note: Change <NEW_PASSWORD> to your desired password.
go
quit
- Close the elevated Command Prompt.
- Repeat steps 1 to 6, but on step 4 remove -m from the Start parameters field, if it exists.
- Install Tomcat 7 package in Diskstation
- Download archiva war file from the following address:
https://archiva.apache.org/index.cgi
- Place the downloaded war file (e.g. apache-archiva-2.2.3.war) into the following directory:
/volume1/@appstore/Tomcat7/src/webapps/
- In MariaDB, add the following user with appropriate password.
archivauser
and the following database
archiva
- Download the following jar files:
mail-1.4.jar mariadb-java-client-1.5.x.jar
- Place the download jar files in the following directory:
/volume1/@appstore/Tomcat7/src/lib
- Create archiva.xml file in the following location:
/volume1/@appstore/Tomcat7/src/conf/Catalina/localhost
Add the following entries:
<?xml version="1.0" encoding="UTF-8"?> <Context path="/archiva" docBase="/volume1/@appstore/Tomcat7/src/webapps/<ARCHIVA_WAR_FILENAME>"> <Resource name="jdbc/users" auth="Container" type="javax.sql.DataSource" username="archivauser" password="<PASSWORD_HERE>" driverClassName="org.mariadb.jdbc.Driver" url="jdbc:mariadb://<MARIADB_HOST_IP>:<MARIADB_HOST_PORT /archiva?autoReconnect=true" /> <Resource name="mail/Session" auth="Container" type="javax.mail.Session" mail.smtp.host="localhost"/> </Context>
Note: The <ARCHIVA_WAR_FILENAME>, <PASSWORD_HERE> <MARIADB_HOST_IP> and <MARIADB_HOST_PORT tokens must be replaced by the downloaded war file from step 2, password used from step 4, IP address of MariaDB and port used by MariaDB repectively.
- Access archiva using the following address:
http://<DISKSTATION_HOST_IP>:7070/archiva
Note: Update the token <DISKSTATION_HOST_IP> with the IP of your Synology Diskstation.
- Install Tomcat 7 package.
- Edit the following file:
/volume1/@appstore/Tomcat7/src/conf/tomcat-users.xml
- Add the following entries:
<role rolename="manager-gui"/> <user username="admin" password="<PASSWORD_HERE>" roles="manager-gui"/>
Note: Update the token <PASSWORD_HERE> appropriately.
- Access the manager-gui using the following address format:
http://<DISKSTATION_HOST_IP>:7070/manager/html
Note: Update the token <DISKSTATION_HOST_IP> with the IP of your Synology Diskstation.


Recent Comments