Object-oriented – Modeling a Call Center in Java (Multi-Thread Approach)

I wanted to try it Model call center from Crack the coding interview, The problem is as follows:

You have a call center with three levels of staff: respondent, manager, director. An incoming call must be assigned to a subscriber who is free. If the respondent is unable to handle the call, he must forward it to a manager. If the manager is not free or unable to handle it, the call should be routed to a director.

Here is my implementation in Java that accepts calls from the command line in the form of: level,duration, For example, enter: 0,25 Represents a call that can be edited by a respondent (Level 0) and takes 25 seconds to complete.

The code should just copy / paste into an IDE or just let it compile javac in case you want to play with it in your local environment. Simply save CallCenter.java in the global package and you are good to go.

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

import static java.lang.Integer.parseInt;

public class CallCenter {

    static BlockingQueue respondantQueue = new ArrayBlockingQueue<>(20);
    static BlockingQueue directorQueue = new ArrayBlockingQueue<>(20);

    static List managers = Arrays.asList(new Manager("Manager - 1"), new Manager("Manager - 2"));

    public static void main(String() args) throws Exception {
        new CallCenter().operate();
    }

    void operate() throws InterruptedException {
        Arrays.asList(new Respondant("Respondant - 1"), new Respondant("Respondant - 2"));
        Arrays.asList(new Director("The Director"));

        System.out.println("Enter values representing call in the format: 0,25.");
        System.out.println("First value is level required, second value is call duration.");
        Scanner scanner = new Scanner(System.in);
        while (true) {
            String s = scanner.nextLine();
            if ("q".equals(s)) {
                break;
            }
            String() split = s.split(",");
            Call call = new Call(parseInt(split(0)), parseInt(split(1)));
            dispatchCall(call);
        }
        scanner.close();
        System.exit(0);
    }

    private void dispatchCall(Call call) throws InterruptedException {
        respondantQueue.put(call);
    }
}

class Call {

    static int idCounter = 0;

    int id;
    int durationInSeconds;
    int level;

    public Call(int level, int durationInSeconds) {
        this.level = level;
        this.durationInSeconds = durationInSeconds;
        this.id = idCounter++;
    }

    @Override
    public String toString() {
        return "Call{" + "id=" + id + ", duration(sec)=" + durationInSeconds + ", level=" + level + '}';
    }
}

class Respondant {
    String name;

    public Respondant(String name) {
        this.name = name;
        new Thread(() -> {
            while (true) {
                try {
                    Call call = CallCenter.respondantQueue.take();
                    if (call.level == 0) {
                        System.out.println(name + " handling call: " + call);
                        Thread.sleep(call.durationInSeconds * 1000);
                    } else {
                        boolean managerHandled = false;
                        for (Manager manager : CallCenter.managers) {
                            if (!manager.isBusy) {
                                manager.acceptCall(call);
                                managerHandled = true;
                                break;
                            }
                        }
                        if (!managerHandled) {
                            CallCenter.directorQueue.put(call);
                        }
                    }
                } catch (InterruptedException ignored) {}
            }
        }).start();
    }
}

class Manager {
    String name;
    volatile boolean isBusy = false;

    public Manager(String name) {
        this.name = name;
    }

    void acceptCall(Call call) {
        new Thread(() -> {
            try {
                isBusy = true;
                if (call.level == 1) {
                    System.out.println(name + " handling call: " + call);
                    Thread.sleep(call.durationInSeconds * 1000);
                } else {
                    CallCenter.directorQueue.put(call);
                }
                isBusy = false;
            } catch (InterruptedException ignored) {}
        }).start();
    }
}

class Director {
    String name;

    public Director(String name) {
        this.name = name;
        new Thread(() -> {
            while (true) {
                try {
                    Call call = CallCenter.directorQueue.take();
                    System.out.println(name + " handling call: " + call);
                    Thread.sleep(call.durationInSeconds * 1000 / 4); // Director handles calls 4 times faster!
                } catch (InterruptedException ignored) {}
            }
        }).start();
    }
}

A test run for me looks like this:

Enter values representing call in the format: 0,25.
First value is level required, second value is call duration.
0,5
Respondant - 1 handling call: Call{id=0, duration(sec)=5, level=0}
0,5
Respondant - 2 handling call: Call{id=1, duration(sec)=5, level=0}
1,5
Manager - 1 handling call: Call{id=2, duration(sec)=5, level=1}
1,5
Manager - 2 handling call: Call{id=3, duration(sec)=5, level=1}
1,5
The Director handling call: Call{id=4, duration(sec)=5, level=1}

Any feedback is welcome.

WelcomeHosting – KVM VPS Specials – No coupon codes, discounts built right into the Los Angeles data center!

WelcomeHosting contacted us in Los Angeles with 2 KVM VPS specials that they wanted to share. This is KVM VPS hosting with pure SSD. By default, all plans support: supported custom kernels, Docker support, SolusVM Control Panel, custom ISO (OS) support, and KVM virtualization

You can find your terms and conditions / legal documents here. You accept PayPal, VISA, MasterCard, American Express, Discover, Bitcoin, Litecoin and Ethereum as a form of payment.

They had to say the following:

"Nowadays, it seems almost impossible to find a hosting company that understands its customers by its first name – not just another number." What is an aspect of home that can not be found anywhere else? Feel comfortable and welcome – and that is exactly what kind of customer experience we want to offer here at WelcomeHosting. We offer many different hosting solutions and are always available to assist you every step of the way. Welcome to a personalized and carefree hosting experience! "

Here are the offers:

2 GB KVM VPS

  • 2048 MB RAM
  • 2x CPU core
  • 30 GB SSD memory
  • 2 TB bandwidth
  • 1 Gbps uplink
  • 1 x IPv4
  • SolusVM / KVM system control
  • Full root access
  • 63 USD / year
  • (ORDER)

4 GB KVM VPS

  • 4096 MB RAM
  • 4x CPU Core
  • 30 GB SSD memory
  • 3 TB bandwidth
  • 1 Gbps uplink
  • 1 x IPv4
  • SolusVM / KVM system control
  • Full root access
  • 125 USD / year
  • (ORDER)

NETWORK INFORMATION:

Buffalo, New York – ColoCrossing Datacenter:

Test IPv4: 192.3.180.103

Test file: http://192.3.180.103/1000MB.test


KVM node:

– 2x Intel Xeon E5-2660v2 CPU

– 128 GB RAM

– 8 hard drives with 1 TB

– LSI Hardware RAID 10

– 1 Gbps uplink

Please let us know if you have any questions / comments and have fun!

[Woktron Web Hosting] DirectAdmin Reseller Hosting (FR-NL-US), New US Data Center (-40% LIFE)

DirectAdmin reseller web hosting based on Woktron's powerful servers and network. Provide your customers world-class web hosting services with unmatched performance and availability by using Woktron's trusted web hosting platform.

————————————————– ————————————————– ——————-
Presentation of our new data center in North Carolina. Use coupon code USA-19 and get one LIFETIME 40% discount

————————————————– ————————————————– ——————-

SILVER

Storage: 40 GB
Traffic: 1000 GB
Domains: 30

9,95 € € 5,97 EURO per month – use coupon code USA-19 For a LIFETIME 40% discount
learn more

IRIDIUM

Hard disk space: 80 GB
Traffic: 2000 GB
Domains: 60

17,95 € 10,77 EURO per month – use coupon code USA-19 For a LIFETIME 40% discount
learn more

GOLD

Hard disk space 120 GB
Traffic: 3000 GB
Areas: 90

24,95 € € 14,97 EURO per month – use coupon code USA-19 For a LIFETIME 40% discount
learn more

PLATINUM

Hard disk space: 200 GB
Traffic: 5000 GB
Domains: Unlimited
Free WHMCS license

39.95 € 23.97 € monthly – use coupon code USA-19 For a LIFETIME 40% discount
learn more

Properties:

  • Direct Admin Control Panel (More information)
  • Softaculous Auto Installer
  • Anti-virus and anti-SPAM
  • Malware cleanup with a mouse click
  • Webmail
  • Website statistics
  • PHP version selection
  • CURL, ImageMagick, GD, Perl, CGI
  • Zend Optimizer, Ioncube
  • Timed tasks
  • Nocturnal backups
  • Unlimited SSL encryption can encrypt
  • Free migrations (including cPanel> DirectAdmin)
  • DDOS mitigation
  • Domain reseller account
  • UPMON Uptime Monitoring with optional e-mail and SMS notifications (SMS notifications require credits that can be purchased separately)
  • Discounted WHMCS. (b) FREE (b) WHMCS with our Platinum Plan
  • Unlimited user accounts for Platinum plans
  • white label
  • …and more!

Data center locations:

  • United States (North Carolina)
  • France (Roubaix)
  • Netherlands (The Hague)

————————————————– ————————————————– —————
All plans include a 30-day money back guarantee!

————————————————– ————————————————– —————

Do you have anymore questions?

Please open a sale ticket as follows this link or you can always chat with us on our website!

Our website
Contact us
Terms of Use

convex analysis – extreme measuring points with a given center of gravity

To let $ X $ be a convex compact measurable subspace of a locally convex topological Hausdorff vector space, $ x_0 in X $, and $ P $ Be the space of all Borel probability measures $ X $ with focus $ x_0 $,

Question: What are the extreme points of $ P $?

In the special case of $ p in P $ Whose support has a finite dimensional span is easily deduced $ p $ is extreme if and only if its support is completely independent. This marks in particular extreme points completely, if $ X $ is finite-dimensional.

I wonder if there is a similar simple / geometric characterization for the general case.

Alignment – Do you want to set read-only Boolean mesh columns to center?

I can not find a reason to align "yes / no" right or center just because they are Boolean values.

The numbers are right-justified so that the reader can more easily perform size comparisons when searching the columns.

If this column is important, you can use Yes / No tags to highlight the information with different background and centered text.

Enter image description here

Train between Vienna Airport and city center

This week I come to Vienna for 2 days. At the moment there are several questions:

  • Does the 48-hour ticket include the train from the airport to the city center?
  • If not, are there ways to not buy a separate ticket but just "expand" the 48-hour ticket?
  • If I get off the train from Vienna to the airport on the way from Vienna Central Cemetery and then continue to the airport, do I have to buy another ticket?
  • Is it better to buy tickets online at the station or in advance?

Is it possible to make an appointment on the same day at the Global Entry Enrollment Center in Taipei (Taipei City, Da # district)?

Is it possible to make an appointment on the same day at the Global Entry Enrollment Center in Taipei (Taipei City, Da # district)?

I could not find any information on the official Global Entry website (https://ttp.cbp.dhs.gov/schedulerui/):

e

JRiver Media Center 25.0.98 Multilingual

JRiver Media Center 25.0.98 Multilingual | 76.3 Mb

JRiver Media Center – All-in-One media management app turns any Windows PC into an entertainment hub for complete control of your digital media: audio, video, images, and television. It connects the PC to stereos, televisions, remote controls, digital cameras, scanners, and portable MP3 players.

It plays all the media, copies, burns and organizes all your music …

JRiver Media Center 25.0.98 Multilingual

Premium, White Label, Reseller Hosting in Europe with cPanel and LSWS | NL or CH Data Center | 25% DISCOUNT

It is well known that reseller web hosting is an ideal way to host and manage multiple clients. It is suitable for marketing agencies, web developers or even web hosting companies that are just starting or trying to develop new locations at low cost.
Our reseller hosting is white label hosting and comes with private (custom) DNS that helps you maintain your brand protection at a high level.

We prepared 25% recurring discount to our reseller hosting packages in Europe.

What do we give with all reseller hosting packages?

Pure SSD memory

DDoS protection

Daily backups

Let's encrypt SSL

Free Website Builder

LiteSpeed ​​Web Server

CloudLinux

PHP version selection

Optimized WordPress

– Professional SPAM filter
– Free Cloudflare CDN
– Guaranteed resources
Restrict security

– No hidden fees or marketing / selling tricks!
– 100% risk-free trial – 45-day money-back guarantee – No questions asked!
– Friendly and professional technical support around the clock
– DC location: Netherlands or Switzerland
—————–

Web hosting packages:

RH1
50 GB of pure SSD storage

cPanel accounts (customer accounts): 50
Private (custom) name servers
Dedicated IP
White label
Over-selling enabled
Unlimited bandwidth

Starts at: 23,96 € / month — more info | Order now!
*Get 25% recurring discount at this price by using of Offer code: RHS191 (more information about the promotion below)

——-

RH2
100 GB of pure SSD storage

cPanel accounts (customer accounts): 100
Private (custom) name servers
Dedicated IP
White label
Over-selling enabled
Unlimited bandwidth

Starts at: 47.96 € / month — more info | Order now!
*Get 25% recurring discount at this price by using of Offer code: RHS191 (more information about the promotion below)

——-

RH3
150 GB of pure SSD storage

cPanel accounts (customer accounts): 150
Private (custom) name servers
Dedicated IP
White label
Over-selling enabled
Unlimited bandwidth

Starts at: 71.96 € / month — more info | Order now!
*Get 25% recurring discount at this price by using of Offer code: RHS191 (more information about the promotion below)

——-

Why AltusHost?

– We have been in business since 2008.
– Fully redundant, Cisco-based network (AS51430)
– Hardware for businesses
– Award-winning 24/7 technical support
– Thousands of happy customers worldwide (some from AltusHost reviews and here)

To facilitate your payments
we accept the following payment methods:
– Card payment (Visa, MasterCard, American Express)
– PayPal
– Bitcoin
– Skrill
– Bank Transfer
– iDeal
– WebMoney (WME)
– PaySafeCard
– Instant Banking
– KBC / CBC Banking
– Bancontact (Mistercash)
– Alipay
– Giropay
– Przelewy24
– Multibanco

———————————-
PROMOTIONAL CODE: RHS191

– Max. Usage per client: 1
Expiration date: 30/09/2019

– Applicable to: All customers
– Discount: recurrently

Discount rate: 25%

– Applicable billing cycles: All billing cycles
———————————-

************************************************** * ***
************************************************** * ***

chat with us @ www.altushost.com // Write us an eMail @ sales@altushost.com // Follow us on Twitter @ AltusHost // Like us on Facebook @ AltusHost Page

************************************************** * ***
************************************************** * ***